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

dedecms织梦手机站去除文章内容中图片的宽高达到自适应,第1张

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

大部分手机站都是自适应的,这样图片就不能有宽高限制,我们添加文章图片时很多时候都会有width height style,在手机站上要把它们清除,又不能影响电脑站的。

{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 = $content;
//@me = str_replace('/uploads/allimg/', $cfg_basehost.'/uploads/allimg/', $content);//手机版图片使用绝对路径
{/dede:field.body}

其中

@me = str_replace('/uploads/allimg/', $cfg_basehost.'/uploads/allimg/', $content);//手机版图片使用绝对路径

上述代码表示手机为二级域名时候,将附件地址改为绝对地址,以防止图片打不开的情况出现。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/3009990.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-09-27
下一篇 2022-09-27

发表评论

登录后才能评论

评论列表(0条)

保存