Image component written in HTL that renders an adaptive image.
- Smart loading of optimal rendition
- In-place editing, cropping, rotating, resizing and image map definition
- Responsive image map resizing
- Image title, description, accessibility text and link
- SVG support
- Styles
- Dynamic Media images support, including Image Presets and Smart Crop
The Image component uses the com.adobe.cq.wcm.core.components.models.Image
Sling Model as its Use-object.
The following configuration properties are used:
./allowedRenditionWidths
- defines the allowed renditions (as an integer array) that will be generated for the images rendered by this component; the actual size will be requested by the client device;./jpegQuality
- defines the image quality for JPEGs (0 lowest quality / size to 100 highest quality / size). Default value is 82../disableLazyLoading
- iftrue
, the lazy loading of images (loading only when the image is visible on the client device) is disabled../lazyThreshold
- defines the number of pixel an image is getting loaded before it gets visible and lazy loading is enabled. Default is set to 0../enableDmFeatures
- iftrue
, Dynamic Media features are enabled../enableAssetDelivery
- Iftrue
, assets will be delivered through the Asset Delivery system (based on Dynamic Media for AEMaaCS). This will also enable optimizations based on content negotiation. Currently, this optimization is available only for webp.
The following properties are written to JCR for this Image component and are expected to be available as Resource
properties:
./fileReference
property orfile
child node - will store either a reference to the image file, or the image file./isDecorative
- if set totrue
, then the image will be ignored by assistive technology./alt
- defines the value of the HTMLalt
attribute (not needed if./isDecorative
is set totrue
)./linkURL
- allows defining a URL to which the image will link to./jcr:title
- defines the value of the HTMLtitle
attribute or the value of the caption, depending on the value of./displayPopupTitle
./displayPopupTitle
- if set totrue
it will render the value of the./jcr:title
property through the HTMLtitle
attribute, otherwise a caption will be rendered./id
- defines the component HTML ID attribute../dmPresetType
- defines the type of Dynamic Media image rendering, possible values areimagePreset
,smartCrop
../imagePreset
- defines the name for the Dynamic Media Image Preset to apply to the Dynamic Media image URL../smartCropRendition
- defines how Dynamic Media Smart Crop image renders.SmartCrop:Auto
means that the component will automatically select Smart Crop rendition which fits the container size better; the name of specific Smart Crop rendition will force the component to render that image rendition only../imageModifiers
- defines additional Dynamic Media Image Serving commands separated by '&'. Field gives complete flexibility to change Dynamic Media image rendering.
- In case you overwrite the image's HTL script, make sure the necessary attributes for the JavaScript loading script are contained in the markup at the right position (see section below).
- In case your own component does not only render an image but does also renders something else, use the following approach:
resourceSuperType
should be set tocore/wcm/components/image/v2/image
(to make sure the image rendering servlet is being used)- Your HTL script should include the image markup via
<div class="cmp-image" data-sly-include="image.html"></div>
- You derived component should reset
cq:htmlTags
- You component's dialog should overwrite the dialog fully from the image component via
sling:hideResource="true"
on the nodecq:dialog/content/items/image
In case Dynamic Media features are not used the images are loaded through the com.adobe.cq.wcm.core.components.internal.servlets.AdaptiveImageServlet
, therefore their URLs have the following patterns:
Author:
/content/<project_path>/<page_path>/<component_path>/<component_name>.coreimg.<quality>.<width>.<extension>/<timestamp>/<filename>.<extension>
Publish:
/content/<project_path>/<page_path>/<component_path>/<component_name>.coreimg.<quality>.<width>.<extension>/<timestamp>/<filename>.<extension>
When an image is a Dynamic Media asset and Dynamic Media features are enabled in component's policy the images are loaded from Dynamic Media Image Serving, the URL format differs depending on image rendering type chosen. In the case of 'Smart Crop':
Author:
/is/image/<company>/<assetId><:smart crop rendition>?ts=<timestamp>&<image modifiers>
Publish:
<DM publish server>/is/image/<company>/<assetId><:smart crop rendition>?ts=<timestamp>&<image modifiers>
In the case of 'Image preset':
Author:
/is/image/<company>/<assetId>?qlt=<quality>&wid=<width>&ts=<timestamp>&$<image_preset>$&<image_modifiers>
Publish:
<dm_publish_server>/is/image/<company>/<assetId>?qlt=<quality>&wid=<width>&ts=<timestamp>&$<image_preset>$&<image_modifiers>
The component provides a core.wcm.components.image.v2
client library category that contains a recommended base
CSS styling and JavaScript component. It should be added to a relevant site client library using the embed
property.
It also provides a core.wcm.components.image.v2.editor
editor client library category that includes JavaScript
handling for dialog interaction. It is already included by its edit dialog.
BLOCK cmp-image
ELEMENT cmp-image__link
ELEMENT cmp-image__image
ELEMENT cmp-image__title
Apply a data-cmp-is="image"
attribute to the wrapper block to enable initialization of the JavaScript component.
The following attributes can be added to the same element to provide options:
data-cmp-lazy
- if notfalse
, indicates that the image should be rendered lazily.data-cmp-src
- the image source. Can be a simple image source, or a URI template representation that can be variable expanded - useful for building an image configuration with an alternative width. Should contain a{.width}
variable. e.g. '/path/to/image.coreimg{.width}.jpeg'data-cmp-widths
- a comma-separated string of alternative image widths (in pixels). Populated withallowedRenditionWidths
from the component's edit dialog.data-cmp-dmimage
- if notfalse
, indicates that the image is DM image.
A hook attribute from the following should be added to the corresponding element so that the JavaScript is able to target it:
data-cmp-hook-image="image"
data-cmp-hook-image="link"
data-cmp-hook-image="noscript"
data-cmp-hook-image="map"
data-cmp-hook-image="area"
The img
and an optional image map
should be placed inside a noscript
element with the data-cmp-hook-image="noscript"
attribute.
They will be inserted into the DOM by the JavaScript component.
To allow lazy loading it is expected that the data-cmp-lazy
and data-cmp-src
options are supplied.
It is possible to configure the JavaScript component such that the most appropriate image url is built and applied to the img
.
The most appropriate width being the one which is at least as wide as the image's container.
The data-cmp-widths
option must be provided with more than one width, as well as the data-cmp-src
option,
with a URI template representation of the source.
To allow responsive recalculation of image map areas, a data-cmp-relcoords
attribute should be added to each map area
. The coordinates
are represented as comma-separated decimal percentages:
<area shape="rect" coords="0,0,10,10" data-cmp-relcoords="0,0,0.5,0.5" href="http://www.adobe.com">
SVG MIME-types are supported, but have some specific handling. Alternative smart image widths defined at the component policy dialog are ignored for SVG images, with Image#getWidths
returning an empty array.
In addition, SVG image types have a more limited set of editing options available in the AEM inline image editor. The lazy loading feature is still supported for SVG images.
- Vendor: Adobe
- Version: v2
- Compatibility: AEM 6.3
- Status: production-ready
- Documentation: https://www.adobe.com/go/aem_cmp_image_v2
- Component Library: https://www.adobe.com/go/aem_cmp_library_image