feat: jxl browser support detection (#25599)

This commit is contained in:
Nicolò Maria Semprini 2026-02-10 18:49:09 +01:00 committed by GitHub
parent adfb003d03
commit 1ddb8f0667
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -303,9 +303,18 @@ const supportedImageMimeTypes = new Set([
const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent); // https://stackoverflow.com/a/23522755
if (isSafari) {
supportedImageMimeTypes.add('image/heic').add('image/heif').add('image/jxl');
supportedImageMimeTypes.add('image/heic').add('image/heif');
}
function checkJxlSupport(): void {
const img = new Image();
img.addEventListener('load', () => {
supportedImageMimeTypes.add('image/jxl');
});
img.src = 'data:image/jxl;base64,/woIAAAMABKIAgC4AF3lEgA='; // Small valid JPEG XL image
}
checkJxlSupport();
/**
* Returns true if the asset is an image supported by web browsers, false otherwise
*/