大部分手机站都是自适应的,这样图片就不能有宽高限制,我们添加文章图片时很多时候都会有width height style,在手机站上要把它们清除,又不能影响电脑站的。
在内容页模板里,用以下标签替换内容标签。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | {dede:field.bodyrunphp=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} |
本页内容由塔灯网络科技有限公司通过网络收集编辑所得,所有资料仅供用户参考了本站不拥有所有权,如您认为本网页中由涉嫌抄袭的内容,请及时与我们联系,并提供相关证据,工作人员会在5工作日内联系您,一经查实,本站立刻删除侵权内容。本文链接:http://www.dengtar.com/9123.html