How does php add domain names to images in the editor? * ** Replace the image in fckedit with the domain name * @ paramstring $ content the content to be replaced * @ paramstring $ the domain name to be added to the image in the strUrl content * @ returnstring * @ eg * functionreplacePicUrl ($ contentnul php adds a domain name to the image in the editor
?
/*** Replace the image in fckedit with the domain name * @ param string $ content the content to be replaced * @ param string $ the domain name to be added to the image in the strUrl content * @ return string * @ eg */function replacePicUrl ($ content = null, $ strUrl = null) {if ($ strUrl) {// extract the src regular expression of the image path and save the result to $ matches preg_match_all ("/] +>/isU ", $ content, $ matches); $ img = ""; if (! Empty ($ matches) {// note that the above regular expression indicates that the src value is placed in the third of the array $ img = $ matches [2];} else {$ img = "";} if (! Empty ($ img) {$ patterns = array (); $ replacements = array (); foreach ($ img as $ imgItem) {$ final_imgUrl = $ strUrl. $ imgItem; $ replacements [] = $ final_imgUrl; $ img_new = "/". preg_replace ("// I", "\/", $ imgItem ). "/"; $ patterns [] = $ img_new;} // sort the array by key ($ patterns); ksort ($ replacements ); // replace content $ vote_content = preg_replace ($ patterns, $ replacements, $ content); return $ vote_content;} else {return $ content ;}}