Home  >  Article  >  CMS Tutorial  >  How to remove the style width height attribute in img in DreamWeaver

How to remove the style width height attribute in img in DreamWeaver

藏色散人
藏色散人Original
2019-12-03 09:13:502256browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn