-
Notifications
You must be signed in to change notification settings - Fork 766
The Adaptive Image Servlet
The AdaptiveImageServlet
is responsible for image processing and streaming.
An image is a Resource with the sling:resourceType property set to core/wcm/components/image or to any other resource type inheriting
from it 1, with either a fileReference property, pointing to a DAM asset, or a file nt:file
subnode, that was uploaded directly to the component node.
Out of the box, the AdaptiveImageServlet comes with the following configurations:
-
sling.servlet.resourceTypes=["core/wcm/components/image"],sling.servlet.selectors=["img"],sling.servlet.extenions=["jpg","jpeg","png","gif"]- for the Core Image v1 URLs -
sling.servlet.resourceTypes=["core/wcm/components/image", "cq/Page"],sling.servlet.selectors=["coreimg"],sling.servlet.extenions=["jpg","jpeg","png","gif"]- for the Core Image v2 URLs
For more details about the servlet's configurations, check the AdaptiveImageServletMappingConfigurationFactory OSGi configuration
factory in the configuration console (/system/console/configMgr).
The URLs to which the AdaptiveImageServlet is bound have the following pattern:
/content/<project_path>/<page_path>/<component_path>/<component_name>.<configured selectors>.<width>.<configured extension>/<timestamp>.<configured extension>
-
<width>defines the client requested width, which is compared against the widths defined by an image's content policy configuration; when this selector is not present, the servlet will resize images to the default resize width, without overscaling; -
<timestamp>defines the last modification date of the currently rendered Image Component; when this suffix is missing or not the expected value, the servlet will redirect the request to the correct URL
The following operations, listed in the order in which they're actually applied, can be executed to an image:
- cropping - based on the value of the
com.day.cq.commons.ImageResource#PN_IMAGE_CROPproperty on the image resource; the value of this property is a CSV list, defining two sets of (x, y) coordinates for the cropping rectangle; - rotation - based on the value of the
com.day.cq.commons.ImageResource#PN_IMAGE_ROTATEproperty on the image resource; the value of this property is an Integer number, defining the rotation angle; - horizontal flipping - based on the value of the
com.adobe.cq.wcm.core.components.models.Image#PN_FLIP_HORIZONTALproperty on the image resource; the value is a Boolean; - vertical flipping - based on the value of the
com.adobe.cq.wcm.core.components.models.Image#PN_FLIP_VERTICALproperty on the image resource; the value is a Boolean; - resizing - based on the
widthrequest selector defined above
1 - all Core Image Component's resource types (core/wcm/components/image/v1/image,
core/wcm/components/image/v2/image) inherit from this resource type