织梦DedeCMS>正文
dedecms处理mip的内容问题img转img-mip
2018-09-10 10:52
在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
如下代码放入:/include/extend.func.php
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;
}
如何调用上面的代码呢。
在模板里面调用:
{dede:field name=’body’ function=’mipBody(@me)’/}
本文链接:https://www.0937.biz/post-341.html
猜你喜欢
- 2018-09-10 织梦安装后提示Function ereg_replace() is deprecated的解决方法
- 2018-09-10 dede数据库批量替换栏目页和内容页标题、关键字、描述
- 2018-09-10 dedecms修改栏目信息报错“保存当前栏目更改时失败,请检查你的输入资料是否存在问题!”
- 2018-09-10 DEDECMS 5.6转5.7数据库升级SQL命令
- 2018-09-10 dedecms指定栏目内关键词替换SQL
- 2018-09-10 DedeCMSV57数据库结构文档
- 2018-09-10 织梦title字数限制的两种方法
- 2018-09-10 dedecms管理员密码重置工具radminpass.php
- 2018-09-10 织梦漏洞文件
- 图文推荐
-
- 热门标签
