• 织梦手机站去除文章内容中图片的宽高达到自适应 绝对路径图片-002cc全讯开户送白菜

  • 专注网站建设 服务热线: 13061801310

织梦手机站去除文章内容中图片的宽高达到自适应 绝对路径图片

发布时间:2021-04-30 | 发布者:  | 浏览次数: 次
大部分手机站都是自适应的,这样图片就不能有宽高限制,我们添加文章图片时很多时候都会有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/', $cfg_basehost.'/uploads/', $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/', $cfg_basehost.'/uploads/', $content);
{/dede:field.content}

转载请标注:——

上一篇:
下一篇:
网站地图