function replaceMipImages($content)
{
preg_match_all('/<img (.*?)\>/', $content, $images);
if(!is_null($images)) { foreach($images[1] as $index => $value){ $mip_img = str_replace('<img', '<mip-img', $images[0][$index]); $mip_img = str_replace('>', '></mip-img>', $mip_img); //以下代码可根据需要修改/删除 $mip_img = preg_replace('/(width|height)="\d*"\s/', '', $mip_img );//移除图片width|height $mip_img = preg_replace('/ style=\".*?\"/', '',$mip_img);//移除图片style $mip_img = preg_replace('/ class=\".*?\"/', '',$mip_img);//移除图片class //以上代码可根据需要修改/删除 $content = str_replace($images[0][$index], $mip_img, $content); } }
return $content; }

 

相关文章:

  • 2021-11-30
  • 2021-06-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-28
  • 2021-09-11
  • 2021-09-07
猜你喜欢
  • 2021-05-18
  • 2021-10-10
  • 2021-10-20
  • 2021-07-25
  • 2022-12-23
相关资源
相似解决方案