Dedecms二級目錄綁定到移動端后訪問就會發現縮略圖和文章內容圖片不顯示,原因是所在目錄與圖片路徑發生了變化,導致的圖片路徑訪問不了。
默認圖片路徑格式是這樣的 /uploads/170127/1-1F12G21245143.jpg
比如我們幫他修改成 https://Vevb.com/uploads/170127/1-1F12G21245143.jpg
下面我們把圖片路徑更換為帶網址的的絕對路徑,就可以解決了。
打開 include/extend.func.php 在最底部增加下面代碼:
function replaceurl($newurl)
{
$newurl=str_replace('src="/uploads/','src="https://Vevb.com/',$newurl);
return $newurl;
}
在文章中,調用代碼
{dede:field.body/} 更換為 {dede:field.body function='replaceurl(@me)'/}
縮略圖可用str_replace函數進行替換
<img src="[field:litpic function='str_replace("/uploads","https://Vevb.com/uploads",@me)'/]" alt="[field:fulltitle/]">
新聞熱點
疑難解答