我最近将我网站上的每张图片都转换为 JP2 以减小文件大小,同时保持透明度。
在 Safari 上一切正常,但 Firefox 不显示 JP2 图像,但它显示 PNG。
Firefox 是否不支持 JP2?
最佳答案
JP2 images are not supported on Firefox .
但您可以使用 <picture>
元素提供多种图像格式,以便浏览器可以选择和显示支持的图像格式:
<picture>
<source srcset="img/example.jp2" type="image/jp2"> <!-- format supported by safari -->
<source srcset="img/example.webp" type="image/webp"> <!-- format supported on many browsers -->
<source srcset="img/example.jpg" type="image/jpeg"> <!-- common supported format -->
<img src="img/example.jpg" alt="example-alt-text"> <!-- default -->
</picture>
注意:JP2 格式的替代方案可以是 WebP 格式:
关于html - Firefox 可以显示 JP2 图像吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54980431/