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

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

藏色散人
Release: 2019-12-03 09:13:50
Original
2315 people have browsed it

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');
Copy after login

在这句代码的下面插入如下代码:

//去除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);
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template