How to extract/create the Dynamic media scene7 URL for the rendition of an asset. | Community
Skip to main content
Level 2
July 14, 2023

How to extract/create the Dynamic media scene7 URL for the rendition of an asset.

  • July 14, 2023
  • 3 replies
  • 3804 views

So what I know is that to create a Dynamic media scene7 URL for an asset is :

 
Also, Through UI, I can see that the url for a rendition is 
 
 
However the rendition title is not there in the rendition jcr data or the metadata. 
 
So How do I get the rendition scene 7 url in sling, or the rendition title?
Any code examples would be nice. Thanks
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

3 replies

AsifChowdhury
Community Advisor
Community Advisor
July 14, 2023

Hi @anuj31005349h74z 

You can try it like this.

import com.adobe.granite.asset.api.Asset; import com.adobe.granite.asset.api.Rendition; // Assuming you have the assetPath and renditionName available // Get the asset using the assetPath Asset asset = assetManager.getAsset(assetPath); // Get the rendition using the renditionName Rendition rendition = asset.getRendition(renditionName); // Get the rendition title String renditionTitle = rendition.getProperties().get("jcr:title", String.class); // Get the rendition scene7 URL String scene7URL = rendition.getPath(); // Example usage String dynamicURL = "https://<scene7_domain_name>/is/image/<company_name>/<asset_name>?$" + renditionTitle + "$";

 

Level 2
July 14, 2023

Well, this does not really work, 

 

rendition.getProperties().get("jcr:title", String.class);

 

rendition.getProperties does not exist, renditions .getValueMap does. and jcr:title is null there.

Also,

 

rendition.getName()

 

gives the name of the node, which is different from what I want. 
It gives this.

 ........

 So you see these are the title of renditions in bold in above image, which is different from the node title in jcr.

What i need is a way to get this title in bold. 

When I click on the URL I get this 

 Now I need to create this URL by getting this title of the rendition.

Level 4
July 14, 2023

Hi @anuj31005349h74z,

When a URL is uploaded to the DAM the static renditions (you have mentioned below in crx under renditions folder). In UI you will notice this as below

 

 

When the Image is synced with S7 the Dynamic renditions as you have shared in the below screenshot would be generated (under heading DYNAMIC) and those can be fetched using  <scene7domain>/is/image/accountname/image filename?$imagepresetname$ 

 

You cannot fetch the static rendition generated by AEM OOB (DAM update asset workflow) using the Scene7 URL and the recommendation is to use create corresponding preset/smart crop rendition and render it on the web page using the S7 URL rather leveraging static renditions. Hope this helps!

 

Dynamic Media documentation : https://experienceleague.adobe.com/docs/experience-manager-cloud-service/content/assets/dynamicmedia/dynamic-media.html?lang=en

Level 2
July 17, 2023

Yes, Thanks for the reply this does give me a direction. Although any idea how can I fetch the image preset names?

Level 2
July 17, 2023

Hi @anuj31005349h74z ,

Please find below the link for creating Dynamic Media Image presets and the configuration

https://experienceleague.adobe.com/docs/experience-manager-65/assets/dynamic/managing-image-presets.html?lang=en

 

  • In general, create the custom project specific DM Presets or Smart crop renditions based on all the custom components we develop
  • Read the specific Preset in the component sling model by the generating the url as below

Example - For Hero component, If the ask is to use a specific Preset, in the hero component sling model construct the url as below to fetch it accordingly. 

<scene7domain>/is/image/accountname/image filename?$heroimagepreset$


Hi @anil_chennapragada The question is In sling java class how do I get the name "heroimagepreset"?

Level 2
July 25, 2023

the correct way to get the dynamic media preset is 

Resource presetsFolderResource = resourceResolver.getResource(S7damConstants.IMAGE_PRESETS);

now the children of this resource will be presets and getting the name will give you Names of the preset.

to create the URL use this formula: <scene7domain>/is/image/<accountname>/<image_filename>?$imagepresetname$