聯(lián)系官方銷售客服
1835022288
028-61286886
之前織夢(mèng)搭建的網(wǎng)站,模板使用了mip的,沒(méi)有分手機(jī)端和PC端,然后都可以正常顯示
現(xiàn)在轉(zhuǎn)迅睿了,然后建的PC,模板也轉(zhuǎn)成迅睿的了,然后圖片顯示不出來(lái)了,我把<mip-img src=""></mip-img>的代碼換成<img src="" />后PC端就可以顯示了,但是手機(jī)端又不能同比例縮放了
各位大佬,有什么解決辦法么?
我是小白一枚,只會(huì)粗淺的一點(diǎn)代碼?。。。?!
http://223987.com/wenda/43619.html
往下拉,手機(jī)端圖片問(wèn)題
回復(fù)迅睿框架創(chuàng)始人 沒(méi)有可以解決的答案,大佬,因?yàn)槲蚁氚芽棄?mèng)網(wǎng)轉(zhuǎn)到迅睿,鏈接不要變,所以我在迅睿里面沒(méi)有建手機(jī)站的,只建PC站,然后現(xiàn)在使用MIP的話,就顯示不出圖片,不使用MIP的話,手機(jī)打開(kāi)網(wǎng)站圖片不會(huì)自動(dòng)縮放
回復(fù)@csmaliya 試試這樣
1、打開(kāi) config/custom.php 加入
/**
* MIP文章內(nèi)容頁(yè)圖片適配百度MIP規(guī)范
*
* @access public
* @param string $content 文章內(nèi)容
* @return string
*/
if(!function_exists('mip'))
{
function mip($content){
preg_match_all('/<img (.*?)\>/', $content, $images);
if(!is_null($images)) {
foreach($images[1] as $index => $value){
$mip_img = str_replace('<img', '<mip-img', $images[0][$index]);
$mip_img = str_replace('>', '></mip-img>', $mip_img);
$mip_img = preg_replace('/(width|height)="\d*"\s/', '', $mip_img );
$mip_img = preg_replace('/ style=\".*?\"/', '',$mip_img);
$content = str_replace($images[0][$index], $mip_img, $content);
}
}
preg_match_all('/ style=\".*?\"/', $content, $style);
if(!is_null($style)) {
foreach($style[0] as $index => $value){
$mip_style = preg_replace('/ style=\".*?\"/', '',$style[0][$index]);
$content = str_replace($style[0][$index], $mip_style, $content);
}
}
$content = str_replace('/uploads/', SITE_URL.'/uploads/', $content);
return $content;
}
}
2、內(nèi)容模板調(diào)用標(biāo)簽
{$content}
改成
{mip($content)}
回復(fù)@云畔設(shè)計(jì) 那MIP不用去動(dòng)么?只要把圖片路徑替換成絕對(duì)路徑就可以了么?不用加手機(jī)端的模板么?
回復(fù)@LandQ 好的,我試試,感謝大佬
回復(fù)@云畔設(shè)計(jì) 好的,感謝大佬,我先試試,得重裝下迅睿才行,被我改的不成樣子了,汗 ?? ?? ??