添加webp图片

hotfix/远程访问多媒体中心
尹诚诚 7 years ago
parent ba5c17c6e5
commit d96fae2a3c

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

Loading…
Cancel
Save