/** * 给ueditor 图片加上https */ function replaceUeditorImage ($content){ preg_match_all('/<img.*?src="(.*?)".*?>/is',$content,$array); $newContent = $content; foreach($array[1] as $k => $v){ $preg = "/^http(s)?:\\/\\/.+/"; if(!preg_match($preg,$v)){ $newContent = str_replace($v,urlhttps($v),$newContent); } } return htmlspecialchars_decode($newContent); } /** * 图片加https域名 * @param $url * @return string */ function urlhttps($url){ if(!empty($url)){ $url = 'http://'.$_SERVER['HTTP_HOST'].$url; } return $url; }
标签:返回,return,url,preg,newContent,content,编辑器,前端,图片 From: https://www.cnblogs.com/mo3408/p/17393055.html