Dynamic media images/videos for custom components | Community
Skip to main content
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

3 replies

EstebanBustamante
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
May 20, 2024

Hi, 

I don't think there is an official approach on how to do this, but in reality, it is not that complicated. You just need to keep in mind that you simply need to invoke a correctly formatted URL and/or load the proper JS (if you are using one of the viewers). With that in mind, you can check how the Core components component does this. Basically, you can check this: https://github.com/adobe/aem-core-wcm-components/blob/main/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/models/v2/ImageImpl.java 

Something like this would work:

String dmAssetName = asset.getMetadataValue(Scene7Constants.PN_S7_FILE); if(isDmFeaturesEnabled && (!StringUtils.isEmpty(dmAssetName))){ //image is DM dmImage = true; //check for publish side boolean isWCMDisabled = (com.day.cq.wcm.api.WCMMode.fromRequest(request) == com.day.cq.wcm.api.WCMMode.DISABLED); //sets to '/is/image/ or '/is/content' based on dam:scene7Type property String dmServerPath; if (asset.getMetadataValue(Scene7Constants.PN_S7_TYPE).equals(Scene7AssetType.ANIMATED_GIF.getValue())) { dmServerPath = DM_CONTENT_SERVER_PATH; } else { dmServerPath = DM_IMAGE_SERVER_PATH; } String dmServerUrl; // for Author if (!isWCMDisabled) { dmServerUrl = dmServerPath; } else { // for Publish dmServerUrl = asset.getMetadataValue(Scene7Constants.PN_S7_DOMAIN) + dmServerPath.substring(1); } dmImageUrl = dmServerUrl + dmAssetName;

 

Hope this helps

Esteban Bustamante
aanchal-sikka
Community Advisor
Community Advisor
May 20, 2024

@sai1278 

 

You can also use IMAGE_DELEGATE to use WCM Core image component to render images, which will also take care of DM aspect. It is used by Teaser as well

 

https://techrevel.blog/2023/09/25/adaptive-image-rendering-via-delegation-for-aem-components/ 

Aanchal Sikka
kautuk_sahni
Community Manager
Community Manager
June 4, 2024

@sai1278 Did you find the suggestions from users helpful? Please let us know if you require more information. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.

Kautuk Sahni
Sai1278Author
Level 3
June 15, 2024

Hi @kautuk_sahni and @aanchal-sikka @estebanbustamante  

I have done recently migration dynamic media clasic 

next step is to update all logic within the system that currently points to static renditions and the old S7 Classic to the new repository URL. This involves migrating from the classic Dynamic Media setup to the native implementation.

Now they want to this rendition $Web1000x1000$ requirement is all images are in sync with dynamic media the rendition we don't have to use the static but the new automatically created from dm7. Please provide some suggestions