yireo / Yireo_Webp2

Magento 2 module to add WebP support to Magento 2
Open Software License 3.0
200 stars 58 forks source link

Issue with using Nginx ngx_http_image_filter_module #102

Open chrisastley opened 3 years ago

chrisastley commented 3 years ago

Hi,

Recently I have started using the new option in Magento for dynamic image resizing based on the URL parameters (https://devdocs.magento.com/guides/v2.4/config-guide/remote-storage/config-remote-storage-image-resize.html)

This has been working great but I recently realised that I had disabled your module while testing and did get around to re-enabling it.

Now that I have enabled it the links in the aren't correct for the srcset items.

<picture class="product-image-photo"> <source type="image/webp" srcset="https://vehiclematsuk.com/media/catalog/product/f/o/ford-mustang-mach-e-car-mats-2020-present-sys2748_qzmopu.webp"> <source type="image/jpg" srcset="https://vehiclematsuk.com/media/catalog/product/f/o/ford-mustang-mach-e-car-mats-2020-present-sys2748_qzmopu.jpg"><img data-hasoptions="1" class="product-image-photo" src="https://vehiclematsuk.com/media/catalog/product/f/o/ford-mustang-mach-e-car-mats-2020-present-sys2748_qzmopu.jpg?width=320&amp;height=320&amp;store=default&amp;image-type=small_image" alt="Ford&amp;#x20;Mustang&amp;#x20;Mach-E&amp;#x20;Car&amp;#x20;Mats&amp;#x20;&amp;#x28;2020-present&amp;#x29;" loading="lazy" width="320" height="320"></picture> You can check here https://vehiclematsuk.com/ford-mustang-car-mats

That is the output on the category page, you can see the img tag has the correct URL along with parameters that allow nginx to serve the resized image, but the 2 srcset image links do not have the parameters so the image is the full-sized original version. This results in the webp image being a lot larger than the resized jpeg in the img.

Not sure what is the best way to resolve this or if it is just as simple as keeping the parameters from the original link and adding to the srcset items?

Thanks

chrisastley commented 3 years ago

Hi,

Thanks for the quick reply, it is Magento. The setting only became available recently, you can see it shown here in the official documentation. https://docs.magento.com/user-guide/configuration/general/web.html#url-options

Magento has also renamed the original method of image caching/thumbnailing as legacy so I'm not sure if they plan to phase it out in favour of dynamic resizing.

chrisastley commented 2 years ago

Hi, can I have a reply on this? You did reply and then deleted it for some reason.

jissereitsma commented 2 years ago

Unfortunately my time has been limited and I have a backlog of numerous open source tickets, this being one of them. I need to work harder to make sure I'm able to pick up on this. I started to reply but realized that I needed quite some time to do anything here. I will try to invest free time in this somewhere in the future, but I can't say when.