Expand my Community achievements bar.

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

Avatar

Level 2

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
9 Replies

Avatar

Community Advisor

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 + "$";

 

Avatar

Level 2

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.
Screenshot 2023-07-14 at 14.56.34.png

 ........

Screenshot 2023-07-14 at 14.40.54.png

 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 

Screenshot 2023-07-14 at 14.41.10.png

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

Avatar

Level 4

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

 

Anil_Chennapragada_0-1689358057561.png

 

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...

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

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....

 

  • 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"?

hi @Anuj1 , It should be hardcoded. Construct the whole DM url and hardcode the preset that needs to be used on the component

 

Or  if you want to keep it dynamic. Add a data page or a generic list and have key , value pair like <componentName, preset name> and read the preset name in the sling model from the data page/ generic list. With this option there will be an option to change the preset needed for a component at any time by authoring it accordingly

the correct way to get the 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.

 

Avatar

Level 2

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$