How in include a AEM dynamic media component into another component



Hi All,

When I tried to include OOTB dynamic media component as part of my component it is throwing exception and it is not allowing me to do so.I have tried like

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

After drag and drop the customComponent(where I have included as above) and view as published mode it is throwing error.


28.02.2019 13:13:23.803 *ERROR* [0:0:0:0:0:0:0:1 [1551320003725] GET /content/we-retail/dynamic-media2.html HTTP/1.1] service: Uncaught SlingException Cannot get DefaultSlingScript: Cannot get DefaultSlingScript: Cannot get DefaultSlingScript: Cannot get DefaultSlingScript: Cannot get DefaultSlingScript: org.mozilla.javascript.EcmaError: TypeError: Cannot call method "replace" of undefined (/libs/dam/components/scene7/dynamicmedia/dynamicmedia_sly.js#470)

Can anyone help me to resolve this issue? How to include OOTB dynamic media component into custom component and how to send parameter to that (i.e Asset path or something) in order to render the dynamic media image on my component.

Accepted Solutions (1)

Accepted Solutions (1)




check /libs/dam/components/scene7/dynamicmedia/dynamicmedia_sly.js#470, you'd see that it requires 'imageserver' url/config and is configured to work in disabled mode

470 - contentPath = imageServer.replace("/is/image", "/is/content");

check if you've configured 'imageserverurl' property or otherwise remote assetpath and

use wcmmode=disabled to test on author.  The code/docs have all you need.



* @param isWCMDisabled

* @return image server URL depending on WCM disabled


function getImageServerURL(isWCMDisabled, assetPath, isRemote){

    var imageServerURL = "";

    if (isWCMDisabled) {

imageServerURL = properties['imageserverurl'];


    else {

        if(isRemote) {

        // get publish server

            var assetResource = resource.getResourceResolver().getResource(assetPath);


        if (assetResource) {

            publishRootPath = sling.getService(;

            return sling.getService(, "");





    return imageServerURL;


Answers (0)