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

本文介绍在MIP规范下,原有HTML标签如<img>、<video>等的使用限制及替换方法,需分别替换成<mip-img>、<mip-video>等MIP兼容标签。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值