Home > Article > CMS Tutorial > How to remove the style width height attribute in img in DreamWeaver
织梦怎么去除img中的style width height属性?
织梦去除img中的style width height属性
在做响应式的织梦模板时,经常会遇到图片无法自适应的问题,原因是织梦的编辑器在上传图片时,会自动加上style属性,因此,在保存文章时,我们需要先清除掉这些属性
推荐学习:织梦cms
在dede/article_add.php中搜索如下代码:
$body = AnalyseHtmlBody($body,$description,$litpic,$keywords,'htmltext');
在这句代码的下面插入如下代码:
//去除img中的style属性 $body = preg_replace("/style=\\\.+?['|\"]/i",'',$body); //去除img中的width,height属性 $exp=Array("/height=.{0,5}\s/i","/width=.{0,5}\s/i"); $exp_o=Array('',''); $body = preg_replace($exp,$exp_o,$body);
The above is the detailed content of How to remove the style width height attribute in img in DreamWeaver. For more information, please follow other related articles on the PHP Chinese website!