手機(jī)網(wǎng)站最重要的一點(diǎn)就是能自適應(yīng),這是因?yàn)槭謾C(jī)屏幕大小太多,需要根據(jù)不同的屏幕大小顯示不同的頁(yè)面尺寸來(lái)適應(yīng)不同的手機(jī)屏幕大小。因此想要實(shí)現(xiàn)自適應(yīng)那么圖片就不能有寬高限制,而我們?cè)谑褂每棄?mèng)系統(tǒng)我們添加文章圖片時(shí)很多時(shí)候都會(huì)有width height style這些屬性在里面,這就會(huì)導(dǎo)致我們?cè)谑謾C(jī)站上看到的圖片都是變形了的。因此我們就要把它們清除并且讓圖片和附件都使用上絕對(duì)路徑,又不能影響電腦站的,不修改程序內(nèi)核文件,我們可以在手機(jī)版內(nèi)容頁(yè)模板里。下面是武林網(wǎng)小編分享給大家的在眾多給用戶處理這個(gè)問(wèn)題的方法。希望能幫助到遇到這樣問(wèn)題朋友。
織夢(mèng)手機(jī)模板如何去除文章內(nèi)容中圖片的寬和高來(lái)自適應(yīng)以及使用絕對(duì)路徑圖片方法介紹。
把手機(jī)站內(nèi)容頁(yè)模板把調(diào)用文章內(nèi)容的標(biāo)簽,找到
{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:/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/', $cfg_basehost.'/uploads/', $content);{/dede:field.body}如果是欄目?jī)?nèi)容的圖片要自適應(yīng)的話那標(biāo)簽
{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=".*?)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/', $cfg_basehost.'/uploads/', $content);{/dede:field.content}效果在請(qǐng)測(cè)試后在給我們一些反饋吧。
新聞熱點(diǎn)
疑難解答
圖片精選