Skip to content

Commit

Permalink
-
Browse files Browse the repository at this point in the history
  • Loading branch information
Hai Zheng committed Dec 13, 2024
1 parent ca5914b commit 071e3d0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/htaccess.cls.php
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = '';
}
Expand Down
9 changes: 7 additions & 2 deletions src/media.cls.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down

0 comments on commit 071e3d0

Please sign in to comment.