織夢(mèng)dedecms默認(rèn)的文章內(nèi)容里面的圖片是固定大小的,這樣在手機(jī)端里面就可能會(huì)導(dǎo)致圖片不能完整顯示,甚至把屏幕撐開,這樣非常不友好,所以361源碼這里就給大家分享一個(gè)方法,讓手機(jī)端的文章內(nèi)容里面的圖片能夠自適應(yīng)圖片大小。

方法如下:
找到并打開手機(jī)端的文章內(nèi)容頁模板,將里面的{dede:field.body/}標(biāo)簽修改一下,改為如下的標(biāo)簽:
{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);//手機(jī)版圖片使用絕對(duì)路徑{/dede:field.body}這段代碼的意思就是通過php代碼將文章內(nèi)容里面的圖片標(biāo)簽的寬度高度全部去掉,這樣就可以了。大家可以去嘗試看看,是否可行!
以上就是DedeCMS手機(jī)端文章內(nèi)容圖片自適應(yīng)的方法的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)和解決疑問有所幫助,也希望大家多多支持武林網(wǎng)。新聞熱點(diǎn)
疑難解答
圖片精選