Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanseifert committed Apr 17, 2024
2 parents ef34652 + 7d40243 commit 315dd58
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 6 deletions.
6 changes: 6 additions & 0 deletions changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
<body>

<release version="2.0.4" date="2024-04-17">
<action type="fix" dev="sseifert" issue="49">
Fix failing to resolve media when enforceVirtualRenditions is enabled and auto cropping is used at the same time.
</action>
</release>

<release version="2.0.2" date="2024-03-13">
<action type="update" dev="sseifert" issue="44">
Next Generation Dynamic Media: Support non-image assets and SVG assets.
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

<groupId>io.wcm</groupId>
<artifactId>io.wcm.handler.media</artifactId>
<version>2.0.2</version>
<version>2.0.4</version>
<packaging>jar</packaging>

<name>Media Handler</name>
Expand All @@ -49,7 +49,7 @@
<site.url.module.prefix>handler/media</site.url.module.prefix>

<!-- Enable reproducible builds -->
<project.build.outputTimestamp>2024-03-13T09:35:13Z</project.build.outputTimestamp>
<project.build.outputTimestamp>2024-04-17T07:52:06Z</project.build.outputTimestamp>
</properties>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

}
2 changes: 1 addition & 1 deletion src/site/markdown/nextgen-dynamic-media.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public class DummyMediaHandlerConfig extends MediaHandlerConfig {
InlineMediaSource.class,
NextGenDynamicMediaMediaSource.class);

private boolean enforceVirtualRenditions;

@Override
public @NotNull List<Class<? extends MediaSource>> getSources() {
return MEDIA_SOURCES;
Expand All @@ -50,4 +52,13 @@ public boolean includeAssetWebRenditionsByDefault() {
return true;
}

@Override
public boolean enforceVirtualRenditions() {
return enforceVirtualRenditions;
}

public void setEnforceVirtualRenditions(boolean enforceVirtualRenditions) {
this.enforceVirtualRenditions = enforceVirtualRenditions;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}

}

0 comments on commit 315dd58

Please sign in to comment.