大部分手机站都是自适应的,这样图片就不能有宽高限制,我们添加文章图片时很多时候都会有width height style,在手机站上要把它们清除,又不能影响电脑站的。
{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/', $cfg_basehost.'/uploads/allimg/', $content);//手机版图片使用绝对路径 {/dede:field.body} |
其中
@me = str_replace('/uploads/allimg/', $cfg_basehost.'/uploads/allimg/', $content);//手机版图片使用绝对路径 |
上述代码表示手机为二级域名时候,将附件地址改为绝对地址,以防止图片打不开的情况出现。
免责声明:本站所有文章和图片均来自用户分享和网络收集,文章和图片版权归原作者及原出处所有,仅供学习与参考,请勿用于商业用途,如果损害了您的权利,请联系网站客服处理。
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
评论(0)