織夢dede手機站去除文章內容中圖片的寬高程序開
導讀:程序開發程序開發大部分手機站都是自適應的,這樣圖片就不能有寬高限制,我們添加文章圖片時很多時候都會有width height style這些屬性在里面,在手機站上要把它們清除,企業網站建設百度seo網站優化。
大部分手機站都是自適應的,這樣圖片就不能有寬高限制,我們添加文章圖片時很多時候都會有width height style這些屬性在里面,在手機站上要把它們清除,又不能影響電腦站的,不修改程序內核文件,我們可以在手機版內容頁模板里, 把手機站 內容頁模板 把調用文章內容的標簽,找到 { dede :field.body/} 改成 {dede:field.body runphp=yes}global $cfg_basehost; $ str = @me; $ search = /(img.*?)width=( […]
把手機站內容頁模板把調用文章內容的標簽,找到
{dede:field.body/}改成
{dede:field.body runphp=yes} global $cfg_basehost; $str = @me; $search = '/(<img.*?)width=([&q網站seo優化診斷工具uot;\'])?.*?(?(2)\2|\s)([^>]+>)/is'; $search1 = '/(<img.*?)height=(["\'])?.*?(?(2)\2|\s)([^>]+>)/is'; $search2 = '#(<img.*?style=".*?)width:\s{0,}\d+px;([^"]*?.*?>)#i'; $search3 = '#(<img.*?style=".*?)height:\s{0,}\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 = str_replace('/uploads/allimg/', $cfg_basehost.'/uploads/allimg/', $conte網站建設公司nt); {/dede:field.body}如果是欄目內容的圖片要自適應的話那標簽
{dede:field.content/}改成
{dede:field.content runphp=yes} global $cfg_basehost; $str = @me; $search = '/(<img.*?)width=(["\'])?.*?(?(2)\2|\s)([^>]+>)/is'; $search1 = '/(<img.*?)height=(["\'])?.*?(?(2)\2|\s)([^>]+>)/is'; $search2 = '#(<img.*?style=".*?)wid企業網站建設th:\s{0,}\d+px;([^"]*?.*?>)#i'; $search3 = '#(<img.*?style=".*?)height:\s{0,}\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 = str_replace('/uploads/allimg/', $cfg_basehost.'/uploads/allimg/', $content); {/dede:field.content}相關企業網站建設百度seo網站優化。聲明: 本文由我的SEOUC技術文章主頁發布于:2023-05-25 ,文章織夢dede手機站去除文章內容中圖片的寬高程序開主要講述文章內容,標簽,手機網站建設源碼以及服務器配置搭建相關技術文章。轉載請保留鏈接: http://www.bifwcx.com/article/web_8550.html