织梦 php MIP改造,织梦dedecms MIP改造图片img转img-mip处理方法
MIP 十分關注頁面速度,也因此禁用了一些引起拖慢速度的HTML 標簽(禁用列表)。例如,標簽會引起瀏覽器的repaint 和reflow,為了避免這些,MIP 提供了替代標簽。下面淘站網為大家介紹d […]
MIP 十分關注頁面速度,也因此禁用了一些引起拖慢速度的HTML 標簽(禁用列表)。例如,標簽會引起瀏覽器的repaint 和reflow,為了避免這些,MIP 提供了替代標簽。下面淘站網為大家介紹dedecms開發中img轉img-mip的處理方法。
在/include/extend.func.php里添加如下代碼
function?mipBody($body)
{
$body?=?str_replace('?style="white-space:pre"',?'',?$body);
preg_match_all('//',?$body,?$images);
if?(!is_null($images))?{
foreach?($images[1]?as?$index?=>?$value)?{
????????????$mip_img?=?str_replace('',?$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;
}
在模板里面調用:
本文地址:織夢dedecms MIP改造圖片img轉img-mip處理方法 https://www.shenqiu123.com/a/jianzhan/ercikaifa/4041.html
總結
以上是生活随笔為你收集整理的织梦 php MIP改造,织梦dedecms MIP改造图片img转img-mip处理方法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: SI/PI仿真概述:有源高速信号、阻抗、
- 下一篇: 威联通建php邮件服务器_威联通TS-5