Home  >  Article  >  Backend Development  >  Add domain name to pictures in editor_PHP tutorial

Add domain name to pictures in editor_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:44:201228browse

/**
* Replace the image in fckedit and add a domain name
* @param string $content The content to be replaced
* @param string $strUrl The domain name to be added to the image in the content
* @return string
* @eg
*/
function replacePicUrl($content = null, $strUrl = null) {
if ($strUrl) {
Extract the src regular expression of the image path formula and store the results in $matches                                                                                                                                                                         matches);
$img = "";
if(!emptyempty($matches)) {
//Note that the above regular expression indicates that the value of src is placed in the third position of the array
$img = $matches[2];
}else {
$img = "";
} }
if (!emptyempty($img)) {                                                                                            array();
$replacements = array();
foreach($img as $imgItem){
$final_imgUrl = $strUrl.$imgIt em;                                                                                                                 🎜>               $img_new = "/".preg_replace("///i","/",$imgItem)."/";                                                                                                                   >                                                                                         //Replacement content
$vote_content = preg_replace($patterns, $replacements , $content);
                                                                                                                                      🎜>}





http://www.bkjia.com/PHPjc/478768.html

www.bkjia.com

true

http: //www.bkjia.com/PHPjc/478768.html

TechArticle

/*** Replace the picture in fckedit and add the domain name * @param string $content The content to be replaced * @param string $strUrl The domain name to be added to the picture in the content * @return string * @eg*/ function r...




Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn