How in include a AEM dynamic media component into another component

Avatar

Avatar

seenivasaragava

Avatar

seenivasaragava

seenivasaragava

27-02-2019

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.

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] org.apache.sling.engine.impl.SlingRequestProcessorImpl service: Uncaught SlingException

org.apache.sling.scripting.sightly.SightlyException: org.apache.sling.api.SlingException: Cannot get DefaultSlingScript: org.apache.sling.api.SlingException: Cannot get DefaultSlingScript: org.apache.sling.api.SlingException: Cannot get DefaultSlingScript: org.apache.sling.api.SlingException: Cannot get DefaultSlingScript: org.apache.sling.api.SlingException: 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)

Avatar

Avatar

Gaurav-Behl

MVP

Total Posts

1.1K

Likes

226

Correct Answer

281

Avatar

Gaurav-Behl

MVP

Total Posts

1.1K

Likes

226

Correct Answer

281
Gaurav-Behl
MVP

28-02-2019

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.

snippet:

/**

* @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(com.day.cq.dam.api.s7dam.utils.PublishUtils).getPublishNodeURL(assetResource);

            return sling.getService(com.day.cq.dam.api.s7dam.utils.PublishUtils).externalizeImageDeliveryAsset(assetResource, "");

        }

        }

       

    }

    return imageServerURL;

}

Answers (0)