Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

How to programmatically set image path in AEM6.4 Dynamic media component

Level 2
Level 2

Hi All,

I have component lets say xyz and I'm including sly-resource "Dynamic Media" component into page like mentioned below,

in XYZ .html:-

<sly data-sly-resource="${ 'dynamic-media' @ resourceType='dam/components/scene7/dynamicmedia'}"/>

It will add the node under  "/content/dam/customwebsite/xyz" as "/content/dam/custom/xyz/dynamic-media" only when we drag and drop an image into it.(into dynamic media component")

I would like to set a image programmatically

Assume before including the dynamic media component I have a image path like

"xyz.imagePath"   (xyz is a java sling model for my xyz component)

is it possible somehow pass this image path programmatically into dynamic media component? Can some one help me?



3 Replies
Community Advisor
Community Advisor

Not sure why you need to use Sling models. Can you please more clarify the requirement?

Drag and drop is best thing in AEM.

Level 2
Level 2

Ok.Forget about the sling model now.

Lets say I have a product Object coming from E-Commerce. That object has product name, description and product image path like mentioned below.

product {

name: "Shirt", description:"men's shirt" , imagePath: "/content/dam/retail/shits/shirt1.jpg"


In my component HTL i can display

Name: ${}

Description: ${product.description}

Product Name:   <---   here I need dynamic media component to be included with the product image --->

So here I can't request author to drag and drop the product images as all the details should come from commerce (including image)

Community Advisor
Community Advisor

In this case, you will have to first upload the images in same path with name in your DAM.

then Accordingly give the service call path where you want the image to be placed.

in this condition, people who are uploading the images, they need to make sure about the path and image name.

Because you are calling image path from service call, then I don't think drag n drop will work here.

~ Prince