Skip to content

Commit

Permalink
Next Generation Dynamic Media/Polaris Remote Assets Support (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanseifert authored Jan 24, 2024
1 parent eaf68bf commit 1e5bed1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
import io.wcm.handler.media.UriTemplate;
import io.wcm.handler.media.UriTemplateType;
import io.wcm.handler.media.format.Ratio;
import io.wcm.handler.mediasource.inline.InlineMediaSource;
import io.wcm.handler.url.UrlHandler;
import io.wcm.sling.models.annotations.AemObject;
import io.wcm.wcm.core.components.commons.link.LinkWrapper;
Expand Down Expand Up @@ -186,14 +187,16 @@ protected List<ImageArea> buildAreas() {
private void initPropertiesFromDamAsset(ValueMap properties) {
Asset asset = media.getAsset();
if (asset != null) {
if (!StringUtils.equals(media.getMediaSource().getId(), InlineMediaSource.ID)) {
fileReference = asset.getPath();
}
alt = asset.getAltText();

com.day.cq.dam.api.Asset damAsset = asset.adaptTo(com.day.cq.dam.api.Asset.class);
if (damAsset != null) {
boolean titleFromAsset = properties.get(PN_TITLE_VALUE_FROM_DAM, currentStyle.get(PN_TITLE_VALUE_FROM_DAM, true));
boolean uuidDisabled = currentStyle.get(PN_UUID_DISABLED, false);

fileReference = damAsset.getPath();
alt = asset.getAltText();

if (!uuidDisabled) {
uuid = damAsset.getID();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
import io.wcm.handler.media.MediaHandler;
import io.wcm.handler.media.MediaNameConstants;
import io.wcm.handler.media.Rendition;
import io.wcm.handler.mediasource.inline.InlineMediaSource;
import io.wcm.sling.commons.adapter.AdaptTo;
import io.wcm.sling.models.annotations.AemObject;
import io.wcm.wcm.core.components.impl.models.helpers.AbstractComponentImpl;
Expand Down Expand Up @@ -152,14 +153,16 @@ private void activate() {
private void initPropertiesFromDamAsset(ValueMap properties) {
Asset asset = media.getAsset();
if (asset != null) {
if (!StringUtils.equals(media.getMediaSource().getId(), InlineMediaSource.ID)) {
fileReference = asset.getPath();
}
alt = asset.getAltText();

com.day.cq.dam.api.Asset damAsset = asset.adaptTo(com.day.cq.dam.api.Asset.class);
if (damAsset != null) {
boolean titleFromAsset = properties.get(PN_TITLE_VALUE_FROM_DAM, currentStyle.get(PN_TITLE_VALUE_FROM_DAM, true));
boolean uuidDisabled = currentStyle.get(PN_UUID_DISABLED, false);

fileReference = damAsset.getPath();
alt = asset.getAltText();

if (!uuidDisabled) {
uuid = damAsset.getID();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
data-cmp-is="wcmio-responsiveimage"
data-asset="${image.fileReference}"
data-asset-id="${image.uuid}"
data-cmp-filereference="${image.fileReference}"
data-title="${image.title || image.alt}"
id="${image.id}"
data-cmp-data-layer="${image.data.json}"
Expand Down

0 comments on commit 1e5bed1

Please sign in to comment.