dedecms处理mip的内容问题img转img-mip

在mip校验下不能直接使用img标签,需要全部更换为img-mip。

如下是MIP禁止使用或要进行替换:

标签 使用范围 备注

<img> 禁止使用 需替换为 <mip-img>

<video> 禁止使用 需替换为 <mip-video>

<audio> 禁止使用 需替换为 <mip-audio>

<iframe> 禁止使用 需替换为 <mip-iframe>

<form> 禁止使用 需替换为 <mip-form>

<frame> 禁止使用

<frameset> 禁止使用

<object> 禁止使用

<param> 禁止使用

<applet> 禁止使用

<embed> 禁止使用

MIP文档:https://www.mipengine.org/doc/2-tech/1-mip-html.html

function mipBody($body)

{

$body = str_replace(' style="white-space:pre"', '', $body);

preg_match_all('/<img (.*?)\>/', $body, $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);

$mip_img = preg_replace('/ style=\".*?\"/', '', $mip_img);

$mip_img = preg_replace('/ class=\".*?\"/', '', $mip_img);

$body = $content = str_replace($images[0][$index], $mip_img, $body);

}

}

return $body;

}

文章地址:https://www.apizl.com/archives/view-134352-1.html

猜你喜欢

转载自blog.csdn.net/moxun2011/article/details/82288975
IMG