Αναζήτηση στην υποστήριξη

Προσοχή στις απάτες! Δεν θα σας ζητήσουμε ποτέ να καλέσετε ή να στείλετε μήνυμα σε κάποιον αριθμό τηλεφώνου ή να μοιραστείτε προσωπικά δεδομένα. Αναφέρετε τυχόν ύποπτη δραστηριότητα μέσω της επιλογής «Αναφορά κατάχρησης».

Μάθετε περισσότερα

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

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'?

Όλες οι απαντήσεις (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?