From: Alexander Ebert Date: Wed, 13 Nov 2024 12:22:10 +0000 (+0100) Subject: Always report browser support for WebP X-Git-Tag: 6.1.1_dev_1~13 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=cddd2b5f4ec7f9715415ab1a908654881af5077b;p=GitHub%2FWoltLab%2FWCF.git Always report browser support for WebP See https://www.woltlab.com/community/thread/309622-keine-auslieferung-von-webp-grafiken-mehr-an-firefox-nutzer/ --- diff --git a/wcfsetup/install/files/lib/util/ImageUtil.class.php b/wcfsetup/install/files/lib/util/ImageUtil.class.php index 84e27fe222..9a7afdded6 100644 --- a/wcfsetup/install/files/lib/util/ImageUtil.class.php +++ b/wcfsetup/install/files/lib/util/ImageUtil.class.php @@ -204,27 +204,21 @@ final class ImageUtil * supports WebP images. * * @since 5.4 + * @deprecated 6.1 */ public static function browserSupportsWebp(): bool { - static $supportsWebP = null; - - if ($supportsWebP === null) { - $supportsWebP = false; - if (!empty($_SERVER["HTTP_ACCEPT"])) { - $acceptableMimeTypes = \array_map(static function ($acceptableMimeType) { - [$mimeType] = ArrayUtil::trim(\explode(";", $acceptableMimeType), false); - - return $mimeType; - }, Header::splitList($_SERVER["HTTP_ACCEPT"])); - - if (\in_array("image/webp", $acceptableMimeTypes)) { - $supportsWebP = true; - } - } - } - - return $supportsWebP; + // WebP is supported in all current browsers. Furthermore, this + // detection uses the “accept” header for the page request which is a + // bit unreliable. Safari has never exposed image formats there and + // Firefox recently decided to drop the support for it in + // https://bugzilla.mozilla.org/show_bug.cgi?id=1917177. + // + // Exposing the recognized image formats in this header is actually in + // violation of the spec and we must therefore expect it to be dropped + // from Chromium based browsers at some point. + // See https://fetch.spec.whatwg.org/#document-accept-header-value + return true; } /**