怎么让dedecms织梦手机站去除文章内容中图片的宽高达到自适应
大部分手机站都是自适应的,这样图片就不能有宽高限制,我们添加文章图片时很多时候
打开include/ arc.archives.class.php,查找代码:
1
2
3 <span class="hljs-comment">/设置全局环境变量</span>
$this->Fields[<span class="hljs-string">'typename'</span>] = $this->TypeLink->TypeInfos[<span class="hljs-string">'typename'</span>];
@SetSysEnv($this->Fields[<span class="hljs-string">'typeid'</span>],$this->Fields[<span class="hljs-string">'typename'</span>],$this->Fields[<span class="hljs-string">'id'</span>],$this->Fields[<span class="hljs-string">'title'</span>],<span class="hljs-string">'archives'</span>);
在下面添加:
1
2 <span class="hljs-comment">//</span><span class="hljs-comment">去</span><span class="hljs-comment">掉</span><span class="hljs-comment">img的width和height</span>
$this->Fields[<span class="hljs-string">'body'</span>] = preg_replace(<span class="hljs-string">"/style="width\:(.*)"/"</span>,<span class="hljs-string">""</span>,$this->Fields[<span class="hljs-string">'body'</span>]);
再添加以下代码:
{dede:field.body runphp=yes}global $cfg_basehost;$str = @me;$search = '/(<img.*?)width=(["\'])?.*?(?(2)\2|\s)([^>]+>)/is';$search1 = '/(<img.*?)height=(["\'])?.*?(?(2)\2|\s)([^>]+>)/is';$search2 = '#(<img.*?style=".*?)width:\d+px;([^"]*?.*?>)#i';$search3 = '#(<img.*?style=".*?)height:\d+px;([^"]*?.*?>)#i';$content = preg_replace($search,'$1$3',$str);$content = preg_replace($search1,'$1$3',$content);$content = preg_replace($search2,'$1$2',$content);$content = preg_replace($search3,'$1$2',$content);@me = $content;@me = str_replace('/uploads/allimg/','http://img.qilatu.com/', $content);{/dede:field.body}
原创文章,转载请注明: 转载自广州SEO
本文链接地址: 怎么让dedecms织梦手机站去除文章内容中图片的宽高达到自适应