From d96fae2a3ccf6264d544dcd5a60f87efe1189adf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=B9=E8=AF=9A=E8=AF=9A?= Date: Thu, 20 Sep 2018 16:47:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0webp=E5=9B=BE=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../third_party/htmlcompressor/controllers/index.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/application/third_party/htmlcompressor/controllers/index.php b/application/third_party/htmlcompressor/controllers/index.php index a274688b..3ad61841 100644 --- a/application/third_party/htmlcompressor/controllers/index.php +++ b/application/third_party/htmlcompressor/controllers/index.php @@ -301,7 +301,13 @@ class Index extends CI_Controller $img_alt = $image->alt; $img_class = $image->class; if (!empty($img_size)) { - $image->outertext = " width}\" height=\"{$img_size->height}\">"; + //添加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 = " width}\" height=\"{$img_size->height}\">"; + } + $image->outertext = " width}\" height=\"{$img_size->height}\" {$img_src_webp}>"; } } foreach ($html_object->find('#content_main') as $content_main) {