From b618903128924f06be82ab6d28f152b0f4773763 Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Tue, 23 Jan 2024 14:25:45 +0100 Subject: [PATCH 1/5] Next Generation Dynamic Media/Polaris Remote Assets Support --- .../webapp/app-root/components/image/v3/image.json | 14 ++++++++++++++ .../wcmio/responsiveimage/v1/responsiveimage.json | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/bundles/core/src/main/webapp/app-root/components/image/v3/image.json b/bundles/core/src/main/webapp/app-root/components/image/v3/image.json index e0b4576b..4042c5cc 100644 --- a/bundles/core/src/main/webapp/app-root/components/image/v3/image.json +++ b/bundles/core/src/main/webapp/app-root/components/image/v3/image.json @@ -70,6 +70,20 @@ } } } + }, + + /** + * Special Smart Crop action for NextGen Dynamic Media + */ + "cq:actions": ["EDITANNOTATE","COPYMOVE","DELETE","INSERT"], + "cq:actionConfigs": { + "ngdm-smartcrop": { + "condition": "CQ.CoreComponents.image.v3.actions.smartCrop.condition", + "handler": "CQ.CoreComponents.image.v3.actions.smartCrop", + "icon": "cropLightning", + "order": "before CONFIGURE", + "text": "Smart Crop" + } } }, diff --git a/bundles/core/src/main/webapp/app-root/components/wcmio/responsiveimage/v1/responsiveimage.json b/bundles/core/src/main/webapp/app-root/components/wcmio/responsiveimage/v1/responsiveimage.json index 9530dc8e..5dfbdb24 100644 --- a/bundles/core/src/main/webapp/app-root/components/wcmio/responsiveimage/v1/responsiveimage.json +++ b/bundles/core/src/main/webapp/app-root/components/wcmio/responsiveimage/v1/responsiveimage.json @@ -81,6 +81,20 @@ } } } + }, + + /** + * Special Smart Crop action for NextGen Dynamic Media + */ + "cq:actions": ["EDITANNOTATE","COPYMOVE","DELETE","INSERT"], + "cq:actionConfigs": { + "ngdm-smartcrop": { + "condition": "CQ.CoreComponents.image.v3.actions.smartCrop.condition", + "handler": "CQ.CoreComponents.image.v3.actions.smartCrop", + "icon": "cropLightning", + "order": "before CONFIGURE", + "text": "Smart Crop" + } } }, From ea744099319ccda42fd134e246192f7a5135334d Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Tue, 23 Jan 2024 17:23:47 +0100 Subject: [PATCH 2/5] set path/alt.text independently of DAM asset --- .../wcm/wcm/core/components/impl/models/v3/ImageV3Impl.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v3/ImageV3Impl.java b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v3/ImageV3Impl.java index 5ee31363..c5749d22 100644 --- a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v3/ImageV3Impl.java +++ b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v3/ImageV3Impl.java @@ -186,14 +186,14 @@ protected List buildAreas() { private void initPropertiesFromDamAsset(ValueMap properties) { Asset asset = media.getAsset(); if (asset != null) { + 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(); } From 6111a7185cfdc2fec2256d7845ac83bef655d5ca Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Tue, 23 Jan 2024 17:26:18 +0100 Subject: [PATCH 3/5] set path/alt.text independently of DAM asset --- .../impl/models/wcmio/v1/ResponsiveImageV1Impl.java | 6 +++--- .../responsiveimage/v1/responsiveimage/responsiveimage.html | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/wcmio/v1/ResponsiveImageV1Impl.java b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/wcmio/v1/ResponsiveImageV1Impl.java index ea8b9b53..56a97a42 100644 --- a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/wcmio/v1/ResponsiveImageV1Impl.java +++ b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/wcmio/v1/ResponsiveImageV1Impl.java @@ -152,14 +152,14 @@ private void activate() { private void initPropertiesFromDamAsset(ValueMap properties) { Asset asset = media.getAsset(); if (asset != null) { + 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(); } diff --git a/bundles/core/src/main/webapp/app-root/components/wcmio/responsiveimage/v1/responsiveimage/responsiveimage.html b/bundles/core/src/main/webapp/app-root/components/wcmio/responsiveimage/v1/responsiveimage/responsiveimage.html index 0ce440be..c9583f1a 100644 --- a/bundles/core/src/main/webapp/app-root/components/wcmio/responsiveimage/v1/responsiveimage/responsiveimage.html +++ b/bundles/core/src/main/webapp/app-root/components/wcmio/responsiveimage/v1/responsiveimage/responsiveimage.html @@ -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}" From 8da533b0eea4f358261b74c47da43bb93290fa49 Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Tue, 23 Jan 2024 18:05:15 +0100 Subject: [PATCH 4/5] fix unit tests --- .../wcm/wcm/core/components/impl/models/v3/ImageV3Impl.java | 5 ++++- .../impl/models/wcmio/v1/ResponsiveImageV1Impl.java | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v3/ImageV3Impl.java b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v3/ImageV3Impl.java index c5749d22..335eafab 100644 --- a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v3/ImageV3Impl.java +++ b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v3/ImageV3Impl.java @@ -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; @@ -186,7 +187,9 @@ protected List buildAreas() { private void initPropertiesFromDamAsset(ValueMap properties) { Asset asset = media.getAsset(); if (asset != null) { - fileReference = asset.getPath(); + 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); diff --git a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/wcmio/v1/ResponsiveImageV1Impl.java b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/wcmio/v1/ResponsiveImageV1Impl.java index 56a97a42..1a624b25 100644 --- a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/wcmio/v1/ResponsiveImageV1Impl.java +++ b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/wcmio/v1/ResponsiveImageV1Impl.java @@ -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; @@ -152,7 +153,9 @@ private void activate() { private void initPropertiesFromDamAsset(ValueMap properties) { Asset asset = media.getAsset(); if (asset != null) { - fileReference = asset.getPath(); + 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); From 3abb3c7688ec26f48844b02a9604fe11535a8d10 Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Wed, 24 Jan 2024 16:46:10 +0100 Subject: [PATCH 5/5] remove smartcrop action --- .../wcmio/responsiveimage/v1/responsiveimage.json | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/bundles/core/src/main/webapp/app-root/components/wcmio/responsiveimage/v1/responsiveimage.json b/bundles/core/src/main/webapp/app-root/components/wcmio/responsiveimage/v1/responsiveimage.json index 5dfbdb24..9530dc8e 100644 --- a/bundles/core/src/main/webapp/app-root/components/wcmio/responsiveimage/v1/responsiveimage.json +++ b/bundles/core/src/main/webapp/app-root/components/wcmio/responsiveimage/v1/responsiveimage.json @@ -81,20 +81,6 @@ } } } - }, - - /** - * Special Smart Crop action for NextGen Dynamic Media - */ - "cq:actions": ["EDITANNOTATE","COPYMOVE","DELETE","INSERT"], - "cq:actionConfigs": { - "ngdm-smartcrop": { - "condition": "CQ.CoreComponents.image.v3.actions.smartCrop.condition", - "handler": "CQ.CoreComponents.image.v3.actions.smartCrop", - "icon": "cropLightning", - "order": "before CONFIGURE", - "text": "Smart Crop" - } } },