What's new in Media Handler 1.7.0 and Link Handler 1.3.0

wcm.io Media Handler and Link Handler are enhanced with a couple of new features helping to build the brand-new WCM Core Components (which are covered by a separate blog post). This post highlights the major features.

Content Policies

Media Handler 1.7.0 comes with support for content policies.

That means it is possible to define the list of allowed media format(s) and auto-cropping mode not only in the Java code or as component properties, but also via content policies assigned to the component. It comes with some predefined dialog snippets that can be used in the design dialogs:

It’s also possible to define advanced responsive image settings for Image HTML tags with sizes attribute or picture with sources elements via content policies or component properties.

See Media Handler Component Properties for a full list of supported properties and features.

TIFF and SVG file formats

With Media Handler 1.7.0 you can also use TIFF and SVG assets or files in your components.

TIFF files are fully supported with all transformations (e.g. cropping, rotation), but are always rendered as JPEG files for displaying them in the web browser.

SVG files provide unlimited scalability, transformations like cropping and rotation are not supported.

If you want to write unit tests using this new file formats, make sure to define additional Java ImageIO plugins in your project as test dependencies.

Image Maps

Media Handler 1.7.0 has now full support for Image Maps produced by the Image In-Place editor of AEM.

They are detected by the media handler and included in the generated markup with a reference to the image HTML element.

Links that are found within the image map area definitions are processed and validated using the Link Handler.

Clear Transformations Action

With the AEM Image In-Place Editor your can apply transformations like cropping and rotation to your image. It may happen that you apply a transformation that no longer fulfills the media format restrictions of your component, e.g. because the width/height is too small after the cropping. In this situation it’s no longer possible to change the cropping because the image is no longer displayed. An ugly workaround was to remove the image and select it again - but this is tedious.

Media Handler 1.7.0 provides a “Clear Transformation” action in it’s customized File Upload GraniteUI component that allows to “reset” the image to it’s initial state.

Workflow to generate Asset rendition metadata

If you are using the Media Handler, some extra metadata needs to be generated for all renditions of any Asset used with it. This metadata contains the real width/height in pixels of each rendition. By default this metadata is generated automatically by a background service, the "wcm.io Media Handler Rendition Metadata Service".

However, if you have assets in your system that were present before installing the media handler with the background service, or for any other reason need to repair/update the metadata of already existing assets you can now use an AEM Workflow with a custom workflow step. This is available since Media Handler 1.6.0.

Details: https://wcm-io.atlassian.net/wiki/spaces/WCMIO/pages/1206583297

“Invalid” API extensions

Sometimes you want to set a non-null Media or Link variable reference to an “invalid” instance. This was difficult before and required constructing a media/link request or synthetic media/link resource that was resolved to an invalid link.

To make this easier both MediaHandler and LinkHandler now provide a invalid() method which directly returns an “invalid” instance.

The link handler stores each link target usually in two properties - one for the link type (e.g. internal, external, media), and one for the link target reference (property name depending on link type). The Link Handler API expects a resource or link request with exactly this information.

AEM itself traditionally, and the same applies to the AEM Sites Core Components, stores the link target in a single field, leaving it up to the implementation to detect the type of the link from the nature of the string. The Link Handler now supports an additional method overload LinkHandler.get(<String>) which is able to resolve such a string, and detect the appropriate link type automatically.

Using this new feature it is also possible to apply a “compatibility mode” for components that were created - and used in production - without Link Handler and are later migrated to a Link Handler concept. By setting a component property like "wcmio:linkTargetUrlFallbackProperty": "link" the link handler falls back to auto-detecting the link target from a single property named "link" when no link type and link target properties following the Link Handler conventions are found in the resource. With this mode it’s no longer required to migrate the link properties in existing content when switching an existing component to the Link Handler.