adobe / aem-core-wcm-components

Standardized components to build websites with AEM.
https://docs.adobe.com/content/help/en/experience-manager-core-components/using/introduction.html
Apache License 2.0
723 stars 737 forks source link

Dynamic Media Image rendered from Experience Fragment fails in Edit mode #2785

Open HitmanInWis opened 2 weeks ago

HitmanInWis commented 2 weeks ago

Bug present as of version: 2.24.7-SNAPSHOT

When dynamic media images render on the author server in Edit/Preview mode, they generally use a relative path to the AEM server at /is/image/<dm-image-path>, only appending the full DM host URL (e.g. https://s7d1.scene7.com/is/image/<dm-image-path>) when rendering as published. This is necessary to allow users to Edit/Preview pages with Assets that are not yet published in Dynamic Media.

When an image component sits within an Experience Fragment (e.g. Header Logo) the DM URL is always rendered with the full DM host URL, causing the image to fail to render if it is not yet published.

This is caused by the fact that the experiencefragment component forces WCMMode to disabled when rendering its contents:

     data-sly-resource="${@path=fragment.localizedFragmentVariationPath, selectors=selector, wcmmode='disabled'}"

A possible solution to this would be to create an author-only servlet filter that captures the "raw" WCMMode at the beginning of a request, allowing the ImageImpl model to check for the "raw" WCMMode when choosing between DM URLs. I'm sure there's other solutions as well.