diff --git a/changes.xml b/changes.xml
index 81edcc1e..4f9f33f3 100644
--- a/changes.xml
+++ b/changes.xml
@@ -23,6 +23,12 @@
xsi:schemaLocation="http://maven.apache.org/changes/1.0.0 http://maven.apache.org/plugins/maven-changes-plugin/xsd/changes-1.0.0.xsd">
+
+
+ Fix failing to resolve media when enforceVirtualRenditions is enabled and auto cropping is used at the same time.
+
+
+
Next Generation Dynamic Media: Support non-image assets and SVG assets.
diff --git a/pom.xml b/pom.xml
index 322b2a39..05c48504 100644
--- a/pom.xml
+++ b/pom.xml
@@ -31,7 +31,7 @@
io.wcm
io.wcm.handler.media
- 2.0.2
+ 2.0.4
jar
Media Handler
@@ -49,7 +49,7 @@
handler/media
- 2024-03-13T09:35:13Z
+ 2024-04-17T07:52:06Z
diff --git a/src/main/java/io/wcm/handler/mediasource/dam/impl/DefaultRenditionHandler.java b/src/main/java/io/wcm/handler/mediasource/dam/impl/DefaultRenditionHandler.java
index cda10b60..1dc431f0 100644
--- a/src/main/java/io/wcm/handler/mediasource/dam/impl/DefaultRenditionHandler.java
+++ b/src/main/java/io/wcm/handler/mediasource/dam/impl/DefaultRenditionHandler.java
@@ -289,7 +289,7 @@ public RenditionMetadata getRendition(MediaArgs mediaArgs) {
return null;
}
- private boolean enforceVirtualRendition(RenditionMetadata rendition, MediaArgs mediaArgs) {
+ protected boolean enforceVirtualRendition(RenditionMetadata rendition, MediaArgs mediaArgs) {
if (rendition.isImage() && !rendition.isVectorImage()) {
if (damContext.getMediaHandlerConfig().enforceVirtualRenditions()) {
return true;
diff --git a/src/main/java/io/wcm/handler/mediasource/dam/impl/TransformedRenditionHandler.java b/src/main/java/io/wcm/handler/mediasource/dam/impl/TransformedRenditionHandler.java
index 70d22392..8e6fc1b3 100644
--- a/src/main/java/io/wcm/handler/mediasource/dam/impl/TransformedRenditionHandler.java
+++ b/src/main/java/io/wcm/handler/mediasource/dam/impl/TransformedRenditionHandler.java
@@ -107,4 +107,10 @@ private VirtualTransformedRenditionMetadata getCropRendition(MediaArgs mediaArgs
mediaArgs.getEnforceOutputFileExtension(), cropDimension, rotation, mediaArgs.getImageQualityPercentage());
}
+ @Override
+ protected boolean enforceVirtualRendition(RenditionMetadata rendition, MediaArgs mediaArgs) {
+ // ignore this setting when already using transformed rendition handler
+ return false;
+ }
+
}
diff --git a/src/site/markdown/nextgen-dynamic-media.md b/src/site/markdown/nextgen-dynamic-media.md
index 8307e8b4..8219a2ec 100644
--- a/src/site/markdown/nextgen-dynamic-media.md
+++ b/src/site/markdown/nextgen-dynamic-media.md
@@ -41,7 +41,7 @@ See system configuration how to enable the metadata service.
### System configuration
-If Next Generation Dynamic Media is enabled for a AEMaaCS instance, it will work out-of-the-box with the Media Handler.
+If Next Generation Dynamic Media is enabled for a AEMaaCS instance, it will work out-of-the-box with the Media Handler. In your project-specific implementation of `io.wcm.handler.media.spi.MediaHandlerConfig` you have to add the media sources implementation `io.wcm.handler.mediasource.ngdm.NextGenDynamicMediaMediaSource` to the list returned by the `getSources()` method (overwrite it from the superclass if required).
The "wcm.io Next Generation Dynamic Media Support" OSGi configuration allows to reconfigure the actual URLs used for the [Assets Delivery API (DM API)][aem-dm-api]. Usually you can stick with the default values which reflect the latest version of the DM API.
diff --git a/src/test/java/io/wcm/handler/media/testcontext/DummyMediaHandlerConfig.java b/src/test/java/io/wcm/handler/media/testcontext/DummyMediaHandlerConfig.java
index d7a2ff99..dd4d016e 100644
--- a/src/test/java/io/wcm/handler/media/testcontext/DummyMediaHandlerConfig.java
+++ b/src/test/java/io/wcm/handler/media/testcontext/DummyMediaHandlerConfig.java
@@ -39,6 +39,8 @@ public class DummyMediaHandlerConfig extends MediaHandlerConfig {
InlineMediaSource.class,
NextGenDynamicMediaMediaSource.class);
+ private boolean enforceVirtualRenditions;
+
@Override
public @NotNull List> getSources() {
return MEDIA_SOURCES;
@@ -50,4 +52,13 @@ public boolean includeAssetWebRenditionsByDefault() {
return true;
}
+ @Override
+ public boolean enforceVirtualRenditions() {
+ return enforceVirtualRenditions;
+ }
+
+ public void setEnforceVirtualRenditions(boolean enforceVirtualRenditions) {
+ this.enforceVirtualRenditions = enforceVirtualRenditions;
+ }
+
}
diff --git a/src/test/java/io/wcm/handler/mediasource/dam/impl/AutoCroppingMediaHandlerTest.java b/src/test/java/io/wcm/handler/mediasource/dam/impl/AutoCroppingMediaHandlerTest.java
index bff652ba..c8233e97 100644
--- a/src/test/java/io/wcm/handler/mediasource/dam/impl/AutoCroppingMediaHandlerTest.java
+++ b/src/test/java/io/wcm/handler/mediasource/dam/impl/AutoCroppingMediaHandlerTest.java
@@ -49,14 +49,14 @@
@ExtendWith(AemContextExtension.class)
class AutoCroppingMediaHandlerTest {
- private final AemContext context = AppAemContext.newAemContext();
+ protected final AemContext context = AppAemContext.newAemContext();
private MediaHandler mediaHandler;
private Asset asset;
private Resource resource;
@BeforeEach
- void setUp() {
+ protected void setUp() {
// register RenditionMetadataListenerService to generate rendition metadata
context.registerInjectActivateService(new AssetSynchonizationService());
context.registerInjectActivateService(new RenditionMetadataListenerService(),
diff --git a/src/test/java/io/wcm/handler/mediasource/dam/impl/AutoCroppingMediaHandler_EnforceVirtualRenditionsTest.java b/src/test/java/io/wcm/handler/mediasource/dam/impl/AutoCroppingMediaHandler_EnforceVirtualRenditionsTest.java
new file mode 100644
index 00000000..472018be
--- /dev/null
+++ b/src/test/java/io/wcm/handler/mediasource/dam/impl/AutoCroppingMediaHandler_EnforceVirtualRenditionsTest.java
@@ -0,0 +1,48 @@
+/*
+ * #%L
+ * wcm.io
+ * %%
+ * Copyright (C) 2024 wcm.io
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+package io.wcm.handler.mediasource.dam.impl;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.osgi.framework.Constants;
+
+import io.wcm.handler.media.spi.MediaHandlerConfig;
+import io.wcm.handler.media.testcontext.DummyMediaHandlerConfig;
+import io.wcm.testing.mock.aem.junit5.AemContextExtension;
+
+/**
+ * Same tests as in {@link AutoCroppingMediaHandlerTest}, but with forced
+ * virtual renditions enabled.
+ */
+@ExtendWith(AemContextExtension.class)
+class AutoCroppingMediaHandler_EnforceVirtualRenditionsTest extends AutoCroppingMediaHandlerTest {
+
+ @Override
+ @BeforeEach
+ protected void setUp() {
+ DummyMediaHandlerConfig config = new DummyMediaHandlerConfig();
+ config.setEnforceVirtualRenditions(true);
+ context.registerService(MediaHandlerConfig.class, config,
+ Constants.SERVICE_RANKING, 500);
+
+ super.setUp();
+ }
+
+}