优先显示webp格式图片

hotfix/远程访问多媒体中心
尹诚诚 7 years ago
parent 588dc87ab7
commit 7aa99919dd

@ -304,11 +304,11 @@ class Index extends CI_Controller
//添加webp图片支持 //添加webp图片支持
$img_src_webp=''; $img_src_webp='';
if(substr($img_src, -4) == '.jpg'){ if(substr($img_src, -4) == '.jpg'){
$img_src_jpg=" <amp-img fallback layout=\"responsive\" class=\"{$img_class}\" alt=\"{$img_alt}\" src=\"{$img_src}\" width=\"{$img_size->width}\" height=\"{$img_size->height}\"></amp-img>"; $img_src_jpg=" <amp-img fallback layout=\"responsive\" class=\"{$img_class}\" alt=\"{$img_alt}\" src=\"{$img_src}\" width=\"{$img_size->width}\" height=\"{$img_size->height}\">";
$img_src_webp=substr($img_src, 0, strlen($img_src) - 4).'.webp'; $img_src_webp=substr($img_src, 0, strlen($img_src) - 4).'.webp';
$img_src_webp = " <amp-img layout=\"responsive\" class=\"{$img_class}\" alt=\"{$img_alt}\" src=\"{$img_src_webp}\" width=\"{$img_size->width}\" height=\"{$img_size->height}\" {$img_src_jpg}></amp-img>"; $img_src_webp = " <amp-img layout=\"responsive\" class=\"{$img_class}\" alt=\"{$img_alt}\" src=\"{$img_src_webp}\" width=\"{$img_size->width}\" height=\"{$img_size->height}\" {$img_src_jpg}></amp-img></amp-img>";
} }
if(!empty($img_src_webp)){ if(!empty($img_src_webp)){
$image->outertext =$img_src_webp; $image->outertext =$img_src_webp;

Loading…
Cancel
Save