kamsar / Dianoga

An automatic image optimizer for the Sitecore media library.
Other
102 stars 45 forks source link

WebP using CDN config does not convert some images #88

Closed alex-finnigan-mando closed 3 years ago

alex-finnigan-mando commented 3 years ago

Version of Dianoga

5.2.0

Environment description

Local Sitecore 9.3 single instance

What configs you have enabled

Dianoga.DisableForSites.config Dianoga.Jpeg.config Dianoga.Png.config Dianoga.WebP.CDN.config Dianoga.WebP.config

Reproducible steps (1... 2... 3...) that cause the issue

Run Dianoga with the above configs enabled. Make sure WebP.CDN settings variable is set to true. Load a page with images and view type in Network tab in dev tools.

What you expected to see, versus what you actually saw

Expected: All JPEGs/PNGs being served as WebP.

Observed: Only some images are actually converted to WebP format. Those that aren't converted appear to have the query string 'extension=webp' set twice. When removing this from the request (after opening the image link in another tab) it appears to convert it correctly. See example request below: http://example.local/-/media/images/promos/example-feature-promo.jpg?extension=webp&extension=webp&h=480&w=640&la=en&hash=E038076A16C63EEE7C4978C804229AF0

Relevant logs

Logs after images are being converted, see that some are not actually converted to WebP: 22488 11:27:50 INFO Dianoga: optimized /Images/Tiles/Square_Promo_480x480.jpg [original size: 480w x 480h 75622 bytes] [final size: 31348 bytes] [saved 44274 bytes / 58.55%] [Optimized in 170ms] [Extension jpg] 25280 11:27:50 INFO Dianoga: optimized /Images/Promos/Example Feature Promo.jpg [original size: 640w x 480h 60251 bytes] [final size: 21232 bytes] [saved 39019 bytes / 64.76%] [Optimized in 254ms] [Extension jpg] 21964 11:27:50 INFO Dianoga: optimized /Images/Tiles/Core_Promo_640x480.jpg [original size: 640w x 480h 100307 bytes] [final size: 45156 bytes] [saved 55151 bytes / 54.98%] [Optimized in 283ms] [Extension jpg] 18576 11:27:50 INFO Dianoga: optimized /Images/CTAs/cta-img-lge.jpg [original size: 4940 bytes] [final size: 1352 bytes] [saved 3588 bytes / 72.63%] [Optimized in 274ms] [Extension webp] 17840 11:27:50 INFO Dianoga: optimized /Images/Logos/Header-Logo.png [original size: 3182 bytes] [final size: 2288 bytes] [saved 894 bytes / 28.10%] [Optimized in 509ms] [Extension webp] 21420 11:27:50 INFO Dianoga: optimized /Images/CTAs/Example-Wide.jpg [original size: 172840 bytes] [final size: 8932 bytes] [saved 163908 bytes / 94.83%] [Optimized in 496ms] [Extension webp]

markgibbons25 commented 3 years ago

I've put in some code to check if the url already has been added and check if it's specified at least once. Fixed in 5.3.0

alex-finnigan-mando commented 3 years ago

That's sorted it, much appreciated @markgibbons25!