Expand my Community achievements bar.

SOLVED

Content-Disposition header on content fragment thumbnails

Avatar

Level 2

Hi everyone,

We have came across an unexpected behavior when requesting a thumbnail image for a content fragment.

Where instead of displaying the thumbnail image in the browser its being downloaded. Upon further investigation, I believe this is caused by the header present in the response "Content-Disposition: attachment"

ZdenekK_0-1649162747322.png

Which is asking the browser to download the image instead of displaying as inline.

 

Is there any other way how to get the image path, which can be used as reference?

Is there a settings which could be changed to remove this header without impacting the platform security?

 

The current path example for the thumbnail image:

http://localhost:4502/content/dam/test/content-fragment/cf_sample1/_jcr_content/thumbnail.png

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

Hi @ZdenekK ,

There are two ways to fix this. You can write a rule at dispatcher rule so that this header will be updated from attachment to inline like this. 

<LocationMatch "\.(?i:txt)|(?i:pdf)|(?i:xml)|(?i:png)$">. -->add all your extensions here
Header set Content-Disposition inline
</LocationMatch>

 

The other approach is to put the configuration in Apache Sling Content Disposition Filter  which is an OOTB service in AEM. Please refer to this: https://aem4beginner.blogspot.com/aem-pdf-is-getting-downloaded-instead

View solution in original post

2 Replies

Avatar

Correct answer by
Employee Advisor

Hi @ZdenekK ,

There are two ways to fix this. You can write a rule at dispatcher rule so that this header will be updated from attachment to inline like this. 

<LocationMatch "\.(?i:txt)|(?i:pdf)|(?i:xml)|(?i:png)$">. -->add all your extensions here
Header set Content-Disposition inline
</LocationMatch>

 

The other approach is to put the configuration in Apache Sling Content Disposition Filter  which is an OOTB service in AEM. Please refer to this: https://aem4beginner.blogspot.com/aem-pdf-is-getting-downloaded-instead