From 071e3d0e1bfd289b47f451de69a02a88f91408f6 Mon Sep 17 00:00:00 2001 From: Hai Zheng Date: Fri, 13 Dec 2024 13:48:20 -0500 Subject: [PATCH] - --- src/htaccess.cls.php | 7 ++++--- src/media.cls.php | 9 +++++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/htaccess.cls.php b/src/htaccess.cls.php index ea3efaaa9..d971c982d 100644 --- a/src/htaccess.cls.php +++ b/src/htaccess.cls.php @@ -589,17 +589,18 @@ private function _generate_rules($cfg) // webp support $id = Base::O_IMG_OPTM_WEBP; if (!empty($cfg[$id]) || (!empty($cfg[Base::O_GUEST]) && !empty($cfg[Base::O_GUEST_OPTM]))) { + $webP_rule = 'RewriteRule .* - [E=Cache-Control:vary=%{ENV:LSCACHE_VARY_VALUE}+webp]'; $new_rules[] = self::MARKER_WEBP . self::MARKER_START; $new_rules[] = 'RewriteCond %{HTTP_ACCEPT} "image/webp"'; - $new_rules[] = 'RewriteRule .* - [E=Cache-Control:vary=%{ENV:LSCACHE_VARY_VALUE}+webp]'; + $new_rules[] = $webP_rule; $new_rules[] = 'RewriteCond %{HTTP_USER_AGENT} iPhone.*Version/(\d{2}).*Safari'; $new_rules[] = 'RewriteCond %1 >13'; - $new_rules[] = 'RewriteRule .* - [E=Cache-Control:vary=%{ENV:LSCACHE_VARY_VALUE}+webp]'; + $new_rules[] = $webP_rule; $new_rules[] = 'RewriteCond %{HTTP_USER_AGENT} Firefox/([0-9]+)'; $new_rules[] = 'RewriteCond %1 >=65'; - $new_rules[] = 'RewriteRule .* - [E=Cache-Control:vary=%{ENV:LSCACHE_VARY_VALUE}+webp]'; + $new_rules[] = $webP_rule; $new_rules[] = self::MARKER_WEBP . self::MARKER_END; $new_rules[] = ''; } diff --git a/src/media.cls.php b/src/media.cls.php index 19f273ffe..6e5f185c5 100644 --- a/src/media.cls.php +++ b/src/media.cls.php @@ -477,8 +477,13 @@ public function webp_support() } if (preg_match('/iPhone OS (\d+)_/i', $_SERVER['HTTP_USER_AGENT'], $matches)) { - $lscwp_ios_version = $matches[1]; - if ($lscwp_ios_version >= 14) { + if ($matches[1] >= 14) { + return true; + } + } + + if (preg_match('/Firefox\/(\d+)/iU', $_SERVER['HTTP_USER_AGENT'], $matches)) { // TODO: Test if needs `/U` + if ($matches[1] >= 65) { return true; } }