Package io.wcm.handler.media
Interface MediaBuilder
@ProviderType
public interface MediaBuilder
Define media handling request using builder pattern.
-
Method Summary
Modifier and TypeMethodDescription@NotNull MediaBuilderAllows to specify a custom alternative text that is to be used instead of the one defined in the the asset metadata.@NotNull MediaBuilderSets additional arguments affection media resolving e.g. media formats.@NotNull MediaBuilderautoCrop(boolean value) Enable or disable auto-cropping mode.@NotNull Mediabuild()Resolve media and return metadata objects that contains all results.io.wcm.handler.commons.dom.HtmlElementResolve media and return directly the markup as DOM element generated by the media markup builder.Resolve media and return directly the markup generated by the media markup builder.buildUrl()Resolve media and get URL to reference it directly.@NotNull MediaBuildercontentDispositionAttachment(boolean value) Set whether Content-Disposition header should be set to attachment.@NotNull MediaBuildercropProperty(@NotNull String cropProperty) Set the name of the property which contains the cropping parameters.@NotNull MediaBuilderdecorative(boolean value) Set whether image is decorative.@NotNull MediaBuilderdownload(boolean value) Set whether to accept only download media formats.@NotNull MediaBuilderdragDropSupport(@NotNull DragDropSupport value) Drag&Drop support for media builder.@NotNull MediaBuilderdummyImage(boolean value) Set whether dummy image is enabled.@NotNull MediaBuilderdummyImageUrl(@NotNull String value) Set URL of custom dummy image.@NotNull MediaBuilderdynamicMediaDisabled(boolean value) Disable dynamic media support.@NotNull MediaBuilderenforceOutputFileExtension(@NotNull String value) Enforces image file type for renditions.@NotNull MediaBuilderfileExtension(@NotNull String value) Set accepted file extension.@NotNull MediaBuilderfileExtensions(@NotNull String @NotNull ... values) Set accepted file extensions.@NotNull MediaBuilderfixedDimension(long widthValue, long heightValue) Use fixed dimensions instead of width from media format or original image@NotNull MediaBuilderfixedHeight(long value) Use fixed height instead of width from media format or original image@NotNull MediaBuilderfixedWidth(long value) Use fixed width instead of width from media format or original image@NotNull MediaBuilderforceAltValueFromAsset(boolean value) Set whether to force alt text from DAM asset description.@NotNull MediaBuilderhostedVideoPlayer(boolean value) Use hosted video player.@NotNull MediaBuilderimageQualityPercentage(@NotNull Double value) Set image quality percentage.@NotNull MediaBuilderimageSizes(@NotNull String sizes, long @NotNull ... widths) Apply responsive image handling for theimgelement based on the primary media format given.@NotNull MediaBuilderimageSizes(@NotNull String sizes, @NotNull MediaArgs.WidthOption @NotNull ... widthOptions) Apply responsive image handling for theimgelement based on the primary media format given.@NotNull MediaBuilderincludeAssetAemRenditions(@NotNull Set<AemRenditionType> value) Set which types of AEM-generated renditions are included.@NotNull MediaBuilderincludeAssetThumbnails(boolean value) Deprecated.@NotNull MediaBuilderincludeAssetWebRenditions(boolean value) Deprecated.Please useincludeAssetAemRenditions(Set)instead.@NotNull MediaBuildermandatoryMediaFormatNames(@NotNull String @NotNull ... values) Sets list of media formats to resolve to.@NotNull MediaBuildermandatoryMediaFormats(@NotNull MediaFormat @NotNull ... values) Sets list of media formats to resolve to.@NotNull MediaBuildermapProperty(@NotNull String mapProperty) Set the name of the property which contains the image map data.@NotNull MediaBuildermediaFormat(@NotNull MediaFormat value) Sets a single media format to resolve to.@NotNull MediaBuildermediaFormatName(@NotNull String value) Sets a single media format to resolve to.@NotNull MediaBuildermediaFormatNames(@NotNull String @NotNull ... values) Sets list of media formats to resolve to.@NotNull MediaBuildermediaFormatOptions(@NotNull MediaArgs.MediaFormatOption @NotNull ... values) Sets list of media formats to resolve to.@NotNull MediaBuildermediaFormats(@NotNull MediaFormat @NotNull ... values) Sets list of media formats to resolve to.@NotNull MediaBuildermediaFormatsMandatory(boolean value) If set to true, media handler never returns a dummy image.@NotNull MediaBuilderpictureSource(@NotNull MediaArgs.PictureSource pictureSource) Apply responsive image handling usingpictureandsourceelements.@NotNull MediaBuilderAdds a custom property that my be used by application-specific markup builders or processors.@NotNull MediaBuilderrefProperty(@NotNull String refProperty) Sets the name of the property from which the media reference path is read, or node name for inline media.@NotNull MediaBuilderrotationProperty(@NotNull String rotationProperty) Set the name of the property which contains the rotation parameter.@NotNull MediaBuilderurlMode(@NotNull io.wcm.handler.url.UrlMode value) Set URL mode.@NotNull MediaBuildervideoManifestFormat(@Nullable String value) Set the preferred video manifest format.@NotNull MediaBuilderwebOptimizedImageDeliveryDisabled(boolean value) Disable web-optimized image delivery.
-
Method Details
-
args
Sets additional arguments affection media resolving e.g. media formats.- Parameters:
mediaArgs- Media arguments- Returns:
- Media builder
-
mediaFormats
Sets list of media formats to resolve to.- Parameters:
values- Media formats- Returns:
- this
-
mandatoryMediaFormats
@NotNull @NotNull MediaBuilder mandatoryMediaFormats(@NotNull @NotNull MediaFormat @NotNull ... values) Sets list of media formats to resolve to. AdditionallymediaFormatsMandatory(boolean)is set to true.- Parameters:
values- Media formats- Returns:
- this
-
mediaFormat
Sets a single media format to resolve to.- Parameters:
value- Media format- Returns:
- this
-
mediaFormatsMandatory
If set to true, media handler never returns a dummy image. Otherwise this can happen in edit mode.- Parameters:
value- Resolving of all media formats is mandatory.- Returns:
- this
-
mediaFormatNames
Sets list of media formats to resolve to.- Parameters:
values- Media format names.- Returns:
- this
-
mandatoryMediaFormatNames
@NotNull @NotNull MediaBuilder mandatoryMediaFormatNames(@NotNull @NotNull String @NotNull ... values) Sets list of media formats to resolve to. AdditionallymediaFormatsMandatory(boolean)is set to true.- Parameters:
values- Media format names.- Returns:
- this
-
mediaFormatName
Sets a single media format to resolve to.- Parameters:
value- Media format name- Returns:
- this
-
mediaFormatOptions
@NotNull @NotNull MediaBuilder mediaFormatOptions(@NotNull @NotNull MediaArgs.MediaFormatOption @NotNull ... values) Sets list of media formats to resolve to.- Parameters:
values- Media formats- Returns:
- this
-
autoCrop
Enable or disable auto-cropping mode.- Parameters:
value- Enables "auto-cropping" mode. If no matching rendition is found it is tried to generate one by automatically cropping another one.- Returns:
- this
-
fileExtensions
Set accepted file extensions.- Parameters:
values- Accepted file extensions- Returns:
- this
-
fileExtension
Set accepted file extension.- Parameters:
value- Accpeted file extension- Returns:
- this
-
enforceOutputFileExtension
Enforces image file type for renditions.By default, renditions are rendered with the same file type as the original rendition (except if the original renditions uses a file type not directly supported in browser, e.g. a TIFF image). With this parameter, it is possible to enforce generating renditions with this file type.
Supported file types: JPEG, PNG
- Parameters:
value- File extension to be used for returned renditions- Returns:
- this
-
urlMode
Set URL mode.- Parameters:
value- URS mode- Returns:
- this
-
fixedWidth
Use fixed width instead of width from media format or original image- Parameters:
value- Fixed width- Returns:
- this
-
fixedHeight
Use fixed height instead of width from media format or original image- Parameters:
value- Fixed height- Returns:
- this
-
fixedDimension
Use fixed dimensions instead of width from media format or original image- Parameters:
widthValue- Fixed widthheightValue- Fixed height- Returns:
- this
-
contentDispositionAttachment
Set whether Content-Disposition header should be set to attachment.- Parameters:
value- Whether to set a "Content-Disposition" header to "attachment" for forcing a "Save as" dialog on the client- Returns:
- this
-
altText
Allows to specify a custom alternative text that is to be used instead of the one defined in the the asset metadata.- Parameters:
value- Custom alternative text. If null or empty, the default alt text from media library is used.- Returns:
- this
-
forceAltValueFromAsset
Set whether to force alt text from DAM asset description.- Parameters:
value- Whether to force to read alt. text from DAM asset description. If not set, the asset description is used as fallback value of no custom alt. text is defined.- Returns:
- this
-
decorative
Set whether image is decorative.- Parameters:
value- Marks this image as "decorative". Alt. text is then explicitly set to an empty string.- Returns:
- this
-
dummyImage
Set whether dummy image is enabled.- Parameters:
value- If set to false, media handler never returns a dummy image. Otherwise this can happen in edit mode.- Returns:
- this
-
dummyImageUrl
Set URL of custom dummy image.- Parameters:
value- Url of custom dummy image. If null default dummy image is used.- Returns:
- this
-
imageQualityPercentage
Set image quality percentage.- Parameters:
value- Image quality in percent (0..1) for images with lossy compression (e.g. JPEG).- Returns:
- this
-
includeAssetAemRenditions
@NotNull @NotNull MediaBuilder includeAssetAemRenditions(@NotNull @NotNull Set<AemRenditionType> value) Set which types of AEM-generated renditions are included.- Parameters:
value- Defines which types of AEM-generated renditions (withcq5dam.prefix) are taken into account when trying to resolve the media request.- Returns:
- this
-
includeAssetThumbnails
Deprecated.Please useincludeAssetAemRenditions(Set)instead.- Parameters:
value- If set to true, thumbnail generated by the DAM asset workflows (with cq5dam.thumbnail prefix) are taken into account as well when trying to resolve the media request.- Returns:
- Media builder
-
includeAssetWebRenditions
Deprecated.Please useincludeAssetAemRenditions(Set)instead.- Parameters:
value- If set to true, web renditions generated by the DAM asset workflows (with cq5dam.web prefix) are taken into account as well when trying to resolve the media request.- Returns:
- Media builder
-
dragDropSupport
Drag&Drop support for media builder.- Parameters:
value- Drag&Drop support- Returns:
- Media builder
-
property
@NotNull @NotNull MediaBuilder property(@NotNull @NotNull String key, @Nullable @Nullable Object value) Adds a custom property that my be used by application-specific markup builders or processors.- Parameters:
key- Property keyvalue- Property value- Returns:
- Media builder
-
imageSizes
Apply responsive image handling for theimgelement based on the primary media format given. If multiple media formats are given the primary media format is the first media format with a ratio.It will add a
srcsetattribute to theimgelement with renditions for each width given, and set thesizesattribute to the sizes string given.- Parameters:
sizes- A valid source size listwidths- Widths for the renditions in thesrcsetattribute (all mandatory). All renditions will use the ratio of the primary media format.- Returns:
- this
-
imageSizes
@NotNull @NotNull MediaBuilder imageSizes(@NotNull @NotNull String sizes, @NotNull @NotNull MediaArgs.WidthOption @NotNull ... widthOptions) Apply responsive image handling for theimgelement based on the primary media format given. If multiple media formats are given the primary media format is the first media format with a ratio.It will add a
srcsetattribute to theimgelement with renditions for each width given, and set thesizesattribute to the sizes string given.- Parameters:
sizes- A valid source size listwidthOptions- Widths for the renditions in thesrcsetattribute. All renditions will use the ratio of the primary media format.- Returns:
- this
-
pictureSource
@NotNull @NotNull MediaBuilder pictureSource(@NotNull @NotNull MediaArgs.PictureSource pictureSource) Apply responsive image handling usingpictureandsourceelements. This will add onesourceelement with anmediaattribute set to the given media string, and asrcsetattribute with renditions for each width given based on the given media format.- Parameters:
pictureSource- Picture source element- Returns:
- this
-
download
Set whether to accept only download media formats.- Parameters:
value- Accept only media formats that have the download flag set.- Returns:
- this
-
videoManifestFormat
Set the preferred video manifest format.- Parameters:
value- Preferred video manifest format- Returns:
- this
-
dynamicMediaDisabled
Disable dynamic media support.- Parameters:
value- If set to true, dynamic media support is disabled even when enabled on the instance.- Returns:
- this
-
webOptimizedImageDeliveryDisabled
Disable web-optimized image delivery.- Parameters:
value- If set to true, web-optimized image delivery is disabled even when enabled on the instance.- Returns:
- this
-
hostedVideoPlayer
Use hosted video player.- Parameters:
value- Whether to use Adobe's hosted video player instead of a streaming manifest, affecting both URL generation and markup (iframe vs. HTML5 video element).- Returns:
- this
-
refProperty
Sets the name of the property from which the media reference path is read, or node name for inline media.- Parameters:
refProperty- Property or node name- Returns:
- Media builder
-
cropProperty
Set the name of the property which contains the cropping parameters.- Parameters:
cropProperty- Property name- Returns:
- Media builder
-
rotationProperty
Set the name of the property which contains the rotation parameter.- Parameters:
rotationProperty- Property name- Returns:
- Media builder
-
mapProperty
Set the name of the property which contains the image map data.- Parameters:
mapProperty- Property name- Returns:
- Media builder
-
build
Resolve media and return metadata objects that contains all results.- Returns:
- Media metadata object. Never null, if the resolving failed the isValid() method returns false.
-
buildMarkup
String buildMarkup()Resolve media and return directly the markup generated by the media markup builder.- Returns:
- HTML markup string (may by an img, div or any other element) or null if resolving was not successful.
-
buildElement
io.wcm.handler.commons.dom.HtmlElement buildElement()Resolve media and return directly the markup as DOM element generated by the media markup builder.- Returns:
- HTML element (may by an img, div or any other element) or null if resolving was not successful.
-
buildUrl
String buildUrl()Resolve media and get URL to reference it directly.- Returns:
- URL pointing to media object or null if resolving was not successful.
-
includeAssetAemRenditions(Set)instead.