How in include a AEM dynamic media component into another component | Community
Skip to main content
seenivasaragava
Level 2
February 28, 2019
Solved

How in include a AEM dynamic media component into another component

  • February 28, 2019
  • 1 reply
  • 1966 views

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.

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 Gaurav-Behl

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;

}

1 reply

Gaurav-Behl
Gaurav-BehlAccepted solution
Level 10
February 28, 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;

}