Mozilla Support में खोजें

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

Firefox 93 on linux returns type of image/png when querying for webp

  • 1 प्रत्युत्तर दें
  • 1 यह समस्या है
  • 12 views
  • के द्वारा अंतिम प्रतियुतर jscher2000 - Support Volunteer

more options

Hmm, not sure mozilla support is the right place, and I can't get 'matrix' working at all, since irc is no longer supported.

I want to use javascript to detect whether the browser has webp support. This is the recommended javascript technique... ``` function canUseWebP() {

   var elem = document.createElement('canvas');    if (!!(elem.getContext && elem.getContext('2d'))) {
       // was able or not to get WebP representation
       return elem.toDataURL('image/webp').indexOf('data:image/webp') == 0;
   }    // very old browser like IE 8, canvas not supported
   return false;

} ``` but elem.toDataURL('image/webp') returns a binary blob that has 'image/png' as a header.

Why does Firefox return 'image/png' when it should return 'image/webp'?

Hmm, not sure mozilla support is the right place, and I can't get 'matrix' working at all, since irc is no longer supported. I want to use javascript to detect whether the browser has webp support. This is the recommended javascript technique... ``` function canUseWebP() { var elem = document.createElement('canvas'); if (!!(elem.getContext && elem.getContext('2d'))) { // was able or not to get WebP representation return elem.toDataURL('image/webp').indexOf('data:image/webp') == 0; } // very old browser like IE 8, canvas not supported return false; } ``` but elem.toDataURL('image/webp') returns a binary blob that has 'image/png' as a header. Why does Firefox return 'image/png' when it should return 'image/webp'?

All Replies (1)

more options

Judging from the following table, it looks like Firefox won't support 'image/webp' as a parameter of toDataURL() until the next release, Firefox 96:

https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL#browser_compatibility

Why do you need to test for WebP support using a script?