* 图片地址替换成压缩URL
* @param string $content 内容
* @param string $suffix 后缀
*/
function get_img_thumb_url($content="",$suffix="")
{
$pregRule = “/<[img|IMG].*?src=[\'|\"](.*?(?:[\.jpg|\.jpeg|\.png|\.gif|\.bmp]))[\'|\"].*?[\/]?>/“;
$content = preg_replace($pregRule, ‘<img src=' . $suffix . '${1} style="max-width:100%">’, $content);
return $content;
}
function ceshi(){
$content = ’
<p style="text-align:center;">
<br />
<span> </span><img title="1567868031548733.png" alt="标题1.png" src=’/public/uploads/ueditor/php/upload/image/20190907/156786.png‘>;
</p>
<br />
<p style="text-align:center;">
<br />
<span> </span><img title="1567868066945492.png" alt="1.png" src=‘/public/uploads/ueditor/php/upload/image/20190907/156786806.png’>;
‘
$contnt = $this->get_img_thumb_url($content,"http://www.***.com");
dump($contnt);
}
’
<p style="text-align:center;">
<br />
<span> </span><img title="1567868031548733.png" alt="标题1.png" src=‘http://www.***.com/public/uploads/ueditor/php/upload/image/20190907/156786.png‘>;
</p>
<br />
<p style="text-align:center;">
<br />
<span> </span><img title="1567868066945492.png" alt="1.png" src=’http://www.***.com/public/uploads/ueditor/php/upload/image/20190907/156786806.png’>;
‘
肤
选择风格关闭