php替换富文本框返回图片路径

public function imageUrl($content) {

    $url = "http://".$_SERVER['SERVER_NAME'];
    $pregRule = "/<[img|IMG].*?src=[\'|\"](.*?(?:[\.jpg|\.jpeg|\.png|\.gif|\.bmp]))[\'|\"].*?[\/]?>/";
    $list = preg_replace($pregRule, '<img src="'.$url.'${1}" style="max-width:100%">', $content);
    return $list;

}

猜你喜欢

转载自blog.51cto.com/pilipala/2155131