kamsar / Dianoga

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

WebP images scale/crop incorrect when using CDN and querystring extension=webp (5.4.1) #125

Open robmaas opened 1 year ago

robmaas commented 1 year ago

Version of Dianoga

5.4.1

Environment description

Sitecore 10.2 with Dianoga 5.4.1 and CDN enabled.

What configs you have enabled

Dianoga.DisableForSite.config Dianoga.Jpeg.config Dianoga.Png.config Dianoga.Strategy.MediaCacheAsync.config Dianoga.WebP.CDN.config Dianoga.WebP.config (web.config handler set to Dianoga.MediaRequestHandler)

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

Start site with WebP.config and WebP.CDN.config enabled, disable MediaProtection for easier testing. Open both URL's:

https://{example.com}/-/media/default%20website/cover.jpg?h=200&w=1200&crop=1&fx=0.08854166&fy=-0.05937505
https://{example.com}/-/media/default%20website/cover.jpg?h=200&w=1200&crop=1&fx=0.08854166&fy=-0.05937505&extension=webp

What you expected to see, versus what you actually saw

Image with same scale/cropping should be returned, instead:

Without extension parameter. https://{example.com}/-/media/default%20website/cover.jpg?h=200&w=1200&crop=1&fx=0.08854166&fy=-0.05937505 returns content-type:image/jpeg and image:

image

With extension parameter. https://{example.com}/-/media/default%20website/cover.jpg?h=200&w=1200&crop=1&fx=0.08854166&fy=-0.05937505&extension=webp returns content-type:image/webp and image:

image

When disabling the CDN configuration and using just the 'normal' WebP configuration (without querystring parameter) it works fine and image content-types are returned based on the accept header.

Relevant logs

No relevant logs.

I cannot find any earlier mention of a similar issue, so if this has already been fixed in later version of Dianoga I'm happy to upgrade. If we can fix this by passing the accept header in Azure CDN instead, that's also an acceptable solution for me. I'm reporting the issue anyway, maybe I'm missing something here?