Enable DynamicMedia for assets served by GraphQL query | Community
Skip to main content
Level 3
July 10, 2023
Solved

Enable DynamicMedia for assets served by GraphQL query

  • July 10, 2023
  • 2 replies
  • 2012 views

I'm using GraphQL to retrieve DAM content from AEM and I get the _publishUrl as 

 

 

 

https://publish-p******.adobeaemcloud.com/content/dam/my-project/folder1/subfolder1/imageName.jpg

 

 

 

I don't want to expose the publish url of my AEM instance. Instead, I have Dynamic Media enabled and I want the url to come from there like :

 

 

https://dev.domain.com/adobe/dynamic/....https://qa.domain.com/adobe/dynamic/....

 

 

 

for Dev, QA and other environments. Is there a way to achieve this?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by EstebanBustamante

According to the documentation you should use the "_dynamicUrl" field on the ImageRef, this is supposed to work only in AEMaaCS

 

Please let me know if that works

 

See more here:

https://experienceleague.adobe.com/docs/experience-manager-cloud-service/content/headless/graphql-api/content-fragments.html?lang=en#web-optimized-image-delivery-in-graphql-queries

https://experienceleague.adobe.com/docs/experience-manager-core-components/using/developing/web-optimized-image-delivery.html?lang=en

 

2 replies

Saravanan_Dharmaraj
Community Advisor
Community Advisor
July 10, 2023

@rakesh_h2 Thats a good RFE(Request For Enhancement). But in the meantime if you want to get the URLs by code you can build the DM URL for an image/video using "Scene7Service"

 

https://developer.adobe.com/experience-manager/reference-materials/6-4/javadoc/com/day/cq/dam/scene7/api/Scene7Service.html

 

 

rakesh_h2Author
Level 3
July 10, 2023

@saravanan_dharmaraj Thanks for the response. Any code snippets to share?

Saravanan_Dharmaraj
Community Advisor
Community Advisor
July 10, 2023

@rakesh_h2 below is the sample code of getting the image/video urls using Scene7Service from WCMUsePojo class.

 

public void setS7DynamicMediaModel() { Scene7Service scene7Service = getSlingScriptHelper().getService(Scene7Service.class); String productionImageServerUrl = StringUtils.stripToEmpty(scene7Service.getPublishServerUrl(this.getResource(), this.getResourceResolver())); String imageServerUrl = scene7Service.getPreviewServerUrl(this.getResource(), this.getResourceResolver()); String previewVideoProxyUrl = scene7Service.getPreviewVideoServerUrl(this.getResource(), this.getResourceResolver()); String productionVideoServerUrl = scene7Service.getPublishVideoServerUrl(this.getResource(), this.getResourceResolver()); }

 

EstebanBustamante
Community Advisor and Adobe Champion
EstebanBustamanteCommunity Advisor and Adobe ChampionAccepted solution
Community Advisor and Adobe Champion
July 10, 2023
rakesh_h2Author
Level 3
July 10, 2023

@estebanbustamante That works. Thank you 🙂