kamsar / Dianoga

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

Caching icons for pdf sitecore items results in caching icon as pdf file #96

Closed lampinge3 closed 2 years ago

lampinge3 commented 3 years ago

Version of Dianoga

5.4.0 Can also be replicated in 5.2.0 and 5.3.0

Environment description

Sitecore 9.3

What configs you have enabled

Dianoga.Jpeg.config Dianoga.Jpeg.Lossy.config Dianoga.Png.config Dianoga.Strategy.MediaCacheAsync.config Dianoga.WebP.config

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

  1. Clear the MediaCache
  2. Navigate to the sitecore media library, bring up any pdf file and note the pdf icon under the "Media" section
  3. Inspect element on the icon, then scroll up to the iframe holding the image (about 2 levels up). Then right click on the iframe src and "open in new tab."
  4. Return to the media library, and view another item.
  5. Click on the same pdf file you viewed in step 2, then scroll down to the media section.

What you expected to see, versus what you actually saw

Expect to see the same pdf logo under media library. Instead, once that logo gets cached by Dianoga, the media section displays an html webpage with error "Failed to load pdf document." image

Relevant logs

There was nothing related to the issue the logs.

Other notes

We are using a custom template for pdfs but this seems unrelated. Our "initials_pdf" template inherits /sitecore/templates/System/Media/Unversioned/Pdf.

twellstx commented 3 years ago

We are having the same issue. The optimization process is changing the icon from a png to a pdf which causes an auto download of the corrupt pdf document every time you interact with the media in the media library.

markgibbons25 commented 2 years ago

Thanks for the great repro steps. Fixed in 5.4.1