| 织梦dedecms默认的文章内容里面的图片是固定大小的,这样在手机端里面就可能会导致图片不能完整显示,甚至把屏幕撑开,这样非常不友好,所以这里就给大家分享一个方法,让手机端的文章内容里面的图片能够自适应图片大小。 方法如下: 找到并打开手机端的文章内容页模板,将里面的{dede:field.body/}标签修改一下,改为如下的标签: {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} 也就是通过php代码将文章内容里面的图片标签的宽度高度全部去掉,这样就可以了。 附后:dede的模板位置 首页模板 \templets\default\index.htm 文章频道首页 bai\templets\default\index_article.htm 文章列表页 \templets\default\list_article.htm 文章内容页 \templets\default\article_article.htm 图集频道首页 \templets\default\index_image.htm 图集列表页 \templets\default\list_image.htm 图集内容页 \templets\default\article_image.htm 图集详细页面 \templets\plus\showphoto.htm |
Copyright © 2002-2024 Iszw.net All Rights Reserved. 川公网安备 51010702002244号
蜀ICP备2020035322号-1 本站已开启 IPv6 访问