diff --git a/changes.xml b/changes.xml index 8f08fb3d..104d95c1 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"> + + + MediaHandlerConfig: Make list of allowed IPE editor types configurable (defaults to "image"). + + + DAM Renditions: Read width/height of rendition lazy, as this can be expensive when not configured properly or Asset metadata is missing for other reasons. diff --git a/src/test/java/io/wcm/handler/media/markup/MediaMarkupBuilderUtilTest.java b/src/test/java/io/wcm/handler/media/markup/MediaMarkupBuilderUtilTest.java index e6ce25dc..9b3b6637 100644 --- a/src/test/java/io/wcm/handler/media/markup/MediaMarkupBuilderUtilTest.java +++ b/src/test/java/io/wcm/handler/media/markup/MediaMarkupBuilderUtilTest.java @@ -23,6 +23,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import java.util.Set; @@ -98,7 +99,6 @@ void setUp() throws Exception { when(componentContext.getEditContext()).thenReturn(editContext); when(editContext.getEditConfig()).thenReturn(editConfig); when(editConfig.getInplaceEditingConfig()).thenReturn(inplaceEditingConfig); - when(inplaceEditingConfig.getConfigPath()).thenReturn("/apps/components/comp1"); when(inplaceEditingConfig.getEditorType()).thenReturn("image"); } @@ -201,4 +201,19 @@ void testCanSetCustomIPECropRatios_AUTO() { assertTrue(MediaMarkupBuilderUtil.canSetCustomIPECropRatios(mediaRequest, componentContext)); } + @Test + void testCanSetCustomIPECropRatios_AUTO_IPEConfigPath() { + MediaRequest mediaRequest = new MediaRequest("/content/dam/path", new MediaArgs().ipeRatioCustomize(IPERatioCustomize.AUTO)); + when(inplaceEditingConfig.getConfigPath()).thenReturn("/apps/components/comp1"); + assertTrue(MediaMarkupBuilderUtil.canSetCustomIPECropRatios(mediaRequest, componentContext)); + } + + @Test + void testCanSetCustomIPECropRatios_AUTO_ExistingRatios() { + MediaRequest mediaRequest = new MediaRequest("/content/dam/path", new MediaArgs().ipeRatioCustomize(IPERatioCustomize.AUTO)); + when(inplaceEditingConfig.getConfigPath()).thenReturn("/apps/components/comp1"); + when(resolver.getResource("/apps/components/comp1/plugins/crop/aspectRatios")).thenReturn(mock(Resource.class)); + assertFalse(MediaMarkupBuilderUtil.canSetCustomIPECropRatios(mediaRequest, componentContext)); + } + }