dedecms处理mip的内容问题img转img-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)'
/}