13760154933

网站建设   设计印刷     企业邮箱

知识/

您当前位置>首页>>知识>>建站知识

dedecms手机版内容页面图片变形修改方法

发表时间:2020-02-21 11:28:09

文章来源:admin

浏览次数:

我们的手机站大多数都是自适应的,图片如果有宽高限制就变形了。添加文章图片时很多时候都会有width height style这些属性在里面,在手机站上要把它们清除,又不能影响电脑站的,不修改程序内核文件,我们可以在手机版内容页模板里,把调用文章内容的标签{dede:field.body/}
替换成
{dede:field.body runphp=yes}
global $cfg_basehost;
$str = @me;
$search = '/(]+>)/is';
$search1 = '/(]+>)/is';
$search2 = '#()#i';
$search3 = '#()#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 = str_replace('/uploads/allimg/', $cfg_basehost.'/uploads/allimg/', $content);//手机版图片使用绝对路径
{/dede:field.body}

单页文章把{dede:field.content/}
替换成
{dede:field.content runphp=yes}
global $cfg_basehost;
$str = @me;
$search = '/(]+>)/is';
$search1 = '/(]+>)/is';
$search2 = '#()#i';
$search3 = '#()#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 = str_replace('/uploads/allimg/', $cfg_basehost.'/uploads/allimg/', $content);//手机版图片使用绝对路径
{/dede:field.body}