Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.

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

Avatar

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?

Thanks

Seeni

3 Replies

Avatar

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.

Avatar

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: ${product.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)

Avatar

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