kamsar / Dianoga

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

WebP images not being generated - Sitecore 10 with CDN enabled #87

Closed boarderjen06 closed 3 years ago

boarderjen06 commented 3 years ago

Version of Dianoga

5.2

Environment description

local development environment - Windows 10 OS with Sitecore 10 standalone environment

What configs you have enabled

Dianoga.DisableForSites.Config Dianoga.Jpeg.config Dianoga.Png.config Dianoga.Strategy.GetMediaStreamSync.config Dianoga.WebP.CDN.config Dianoga.WebP.config Changed sitecore_media.ashx path type in the web.donfig to use Dianoga.

Note I also tried enabling the following set of configs instead, but had the same results: Dianoga.DisableForSites.Config Dianoga.Jpeg.config Dianoga.Png.config Dianoga.Strategy.MediaCacheAsync.config Dianoga.WebP.config Return sitecore_media.ashx to original, pointing at Sitecore's Media Request Handler

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

  1. Recycle App Pool
  2. Delete MediaCache folder
  3. Load site in browser
  4. Look at MediaCache folder and inside all subfolders. I am not seeing any webp images, only jpg, png or gif.

What you expected to see, versus what you actually saw

Relevant logs

There are many messages like this in the Sitecore log file: Dianoga: optimized /FILEPATH HERE .jpg [original size: 320w x 280h 14041 bytes] [final size: 10273 bytes] [saved 3768 bytes / 26.84%] [Optimized in 265ms] [Extension jpg]

And there are some messages like this: Dianoga: messages occurred while optimizing /FILEPATH HERE: MozJpegOptimizer: the optimized image resulted in a larger file size (68331 vs 53598). Using the original instead.

There is nothing in the log file related to image compression with "webp", and no errors related to Dianoga.

Here are contents for an example ini file: [key] ?as=False&bc=0&h=0&iar=False&mh=0&mw=0&sc=0&thn=False&w=0

[extension] jpg

[headers] Content-Type: image/jpeg

[dataFile] 179ee381b1f149188bfb04ca056f24de.jpg

;-----

[key] ?as=False&bc=0&h=280&iar=False&mh=0&mw=0&sc=0&thn=False&w=320

[extension] jpg

[headers] Content-Type: image/jpeg

[dataFile] 0c87bc4077d2488ea1a3b85e8511ffa5.jpg

;-----

markgibbons25 commented 3 years ago

A couple things to check:

  1. you shouldn't have both Dianoga.Strategy.GetMediaStreamSync.config and Dianoga.WebP.CDN.config enabled, if you want CDN then just Dianoga.WebP.CDN.config but please read through the comments in Dianoga.WebP.CDN.config to understand
  2. you definitely need the sitecore_media.ashx change to get this working so hopefully the above sorts this for you.
alexFinn97 commented 3 years ago

Also having the exact same issue. Although I'm running on Sitecore 9.3, I've only got the Dianoga.WebP.CDN.config enabled for CDN usage and have done the change for sitecore_media.ashx

markgibbons25 commented 3 years ago

This might be fixed in 5.3.0 please can you check? There may have been a race condition.

alexFinn97 commented 3 years ago

Hi @markgibbons25, just updated the nuget package to 5.3.0 and that's sorted it!

Thanks for the help :)