4

This might be simple question.

How to get different renditions of an image in jsp ?

For example

<img src"/content/dam/travel/Desert.png" />

image has 48x48 and 140x100 etc renditions. How to access these in the component jsp ?

I appreciate the help!

Thank you, Sri

Sri
  • 1,205
  • 2
  • 21
  • 52

3 Answers3

2

You can do next on jsp page of your component:

<%@include file="/libs/foundation/global.jsp" %>
<%
    ResourceResolver resolver = slingRequest.getResourceResolver();

    AssetManager assetManager = resolver.adaptTo(AssetManager.class);

    Asset asset = assetManager.getAsset("/content/dam/travel/Desert.png");

    List<Rendition> renditionList = asset.getRenditions();

    //Now iterate through the renditionList to get the absolute path of each renditon for the specified asset 
    eachRendition.getPath();
%>
Oleksandr Tarasenko
  • 1,454
  • 15
  • 21
user3721455
  • 51
  • 1
  • 5
2

If you open an asset in the DAM, you can see the renditions on the right hand side. If you double click them, they will open in a new tab/window where you can see the direct url. In your case I'd guess the urls would be:

<img src"/content/dam/travel/Desert.png/jcr:content/renditions/cq5dam.thumbnail.48.48.png" />
<img src"/content/dam/travel/Desert.png/jcr:content/renditions/cq5dam.thumbnail.140.00.png" />
Thomas
  • 6,325
  • 4
  • 30
  • 65
0

If you want custom rendition : Go on http://<author_ip>:4502/cf#/conf/global/settings/workflow/models/dam/update_asset.html

Double click on Process Thumbnails.

In Thumbnails section you can see default rendition :

  • 140:100:false
  • 48:48:false
  • 319:319:false

Below, you can add new rendition on Add Item .

Do not forget to save after editing.

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Sep 16 '22 at 04:27