jscher2000 / Save-webP-as-extension

Firefox extension to overlay format and JPEG quality buttons on inline or stand-alone images for quickly saving a converted version of the image.
Mozilla Public License 2.0
32 stars 1 forks source link

Can't convert images which have an empty filename (.jpeg) #6

Closed syldub69 closed 2 years ago

syldub69 commented 2 years ago

Hi,

A lot of websites generate images with empty filename (just file extension). For instance if you go to: https://www.leroymerlin.fr/produits/chauffage-plomberie/chauffage-electrique/radiateur-electrique/radiateur-electrique-sauter/radiateur-electrique-connecte-sauter/radiateur-electrique-double-systeme-chauffant-2000w-sauter-malao-horizontal-bl-70485765.html If you open the first image in a new tab, you see that the image url is: https://m2.lmcdn.fr/media/1/5bc633fb7eb45f2a427b3fc6/.jpeg?width=650&height=650&format=jpg&quality=80&fit=bounds In this case, the Save webP extension can't work. If we add a filename in the url, it works: https://m2.lmcdn.fr/media/1/5bc633fb7eb45f2a427b3fc6/test.jpeg?width=650&height=650&format=jpg&quality=80&fit=bounds

Could you handle this particular case? I think you have to modify the url before exporting image. Maybe you could add an option to automatically add a custom filename for the images which have empty filename. And give the ability to define this custom filename (for instance I would use download date + download time).

jscher2000 commented 2 years ago

I think I can detect whether the first character of the file name (last part of the URL before ?) is a period, then it needs some text before that. The default could be unnamed, but it would be handy to use part of the site name or draw from other clues. I might start with the emergency fix and then think about more options later.

jscher2000 commented 2 years ago

I just uploaded version 1.1 which combines has a partial fix for this issue. Let me know whether that works for you.

In your example, there is a lot of information in the path which could in theory be added into the name, but I'm not sure that's a universal solution. It would be useful to see more examples of sites like this to decide on how best to proceed further.

syldub69 commented 2 years ago

Hi, Yes, it works well! Thanks!