Package io.wcm.handler.media
Class MediaArgs
java.lang.Object
io.wcm.handler.media.MediaArgs
- All Implemented Interfaces:
Cloneable
Holds parameters to influence the media resolving process.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classImage sizes for responsive image handling.static final classMedia format to be applied on media processing.static final classPicture source for responsive image handling.static final classWidth value with mandatory flag. -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructorMediaArgs(@NotNull MediaFormat @NotNull ... mediaFormats) Create media arguments with media formats.Create media arguments with media format names. -
Method Summary
Modifier and TypeMethodDescription@NotNull MediaArgsAllows to specify a custom alternative text that is to be used instead of the one defined in the the asset metadata.@NotNull MediaArgsautoCrop(boolean value) Enable or disable auto-cropping mode.clone()Custom clone-method forMediaArgs@NotNull MediaArgscontentDispositionAttachment(boolean value) Set whether Content-Disposition header should be set to attachment.@NotNull MediaArgsdecorative(boolean value) Set whether image is decorative.@NotNull MediaArgsdownload(boolean value) Set whether to accept only download media formats.@NotNull MediaArgsdragDropSupport(@NotNull DragDropSupport value) Drag&Drop support for media builder.@NotNull MediaArgsdummyImage(boolean value) Set whether dummy image is enabled.@NotNull MediaArgsdummyImageUrl(@Nullable String value) Set URL of custom dummy image.@NotNull MediaArgsdynamicMediaDisabled(boolean value) Set whether dynamic media support is disabled.@NotNull MediaArgsenforceOutputFileExtension(@Nullable String value) Enforces image file type for renditions.boolean@NotNull MediaArgsfileExtension(@Nullable String value) Set accepted file extension.@NotNull MediaArgsfileExtensions(@NotNull String @Nullable ... values) Set accepted file extensions.@NotNull MediaArgsfixedDimension(long widthValue, long heightValue) Use fixed dimensions instead of width from media format or original image@NotNull MediaArgsfixedHeight(long value) Use fixed height instead of width from media format or original image@NotNull MediaArgsfixedWidth(long value) Use fixed width instead of width from media format or original image@NotNull MediaArgsforceAltValueFromAsset(boolean value) Set whether to force alt text from DAM asset description.@Nullable StringGet custom alternative text.@NotNull DragDropSupportDrag&Drop support for media builder.@Nullable StringGet URL of custom dummy image.@Nullable StringEnforces image file type for renditions.String @Nullable []Get accepted file extensions.longUse fixed height instead of width from media format or original imagelongUse fixed width instead of width from media format or original image@Nullable DoubleGet image quality percentage.@Nullable MediaArgs.ImageSizesGet image sizes for responsive image handling.@Nullable Set<AemRenditionType> Get which types of AEM-generated renditions are included.Get IPE ratio customization setting.String @Nullable []Returns list of media formats to resolve to.MediaArgs.MediaFormatOption @Nullable []Gets list of media formats to resolve to.MediaFormat @Nullable []Returns list of media formats to resolve to.MediaArgs.PictureSource @Nullable []Get picture sources for responsive image handling.@NotNull org.apache.sling.api.resource.ValueMapCustom properties that my be used by application-specific markup builders or processors.@Nullable io.wcm.handler.url.UrlModeGet URL mode.@Nullable StringGet the preferred video manifest format.inthashCode()@NotNull MediaArgshostedVideoPlayer(boolean value) Set whether to use hosted video player.@NotNull MediaArgsimageQualityPercentage(@Nullable Double value) Set image quality percentage.@NotNull MediaArgsimageSizes(@Nullable MediaArgs.ImageSizes value) Set image sizes for responsive image handling.@NotNull MediaArgsincludeAssetAemRenditions(@Nullable Set<AemRenditionType> value) Set which types of AEM-generated renditions are included.@NotNull MediaArgsincludeAssetThumbnails(boolean value) Deprecated.@NotNull MediaArgsincludeAssetWebRenditions(boolean value) Deprecated.UseincludeAssetAemRenditions(Set)instead.@NotNull MediaArgsipeRatioCustomize(@Nullable IPERatioCustomize value) Set IPE ratio customization setting.booleanCheck if auto-cropping mode is enabled.booleanCheck if Content-Disposition header should be set to attachment.booleanCheck if image is marked as decorative.booleanCheck if only download media formats are accepted.booleanCheck if dummy image is enabled.booleanCheck if dynamic media support is disabled.booleanCheck if alt text should be forced from DAM asset description.booleanCheck if hosted video player is enabled.@Nullable BooleanDeprecated.UseincludeAssetAemRenditions(Set)instead.@Nullable BooleanDeprecated.UseincludeAssetAemRenditions(Set)instead.booleanCheck if web-optimized image delivery is disabled.@NotNull MediaArgsmandatoryMediaFormatNames(@NotNull String @Nullable ... names) Sets list of media formats to resolve to.@NotNull MediaArgsmandatoryMediaFormats(@NotNull MediaFormat @Nullable ... values) Sets list of media formats to resolve to.@NotNull MediaArgsmediaFormat(MediaFormat value) Sets a single media format to resolve to.@NotNull MediaArgsmediaFormatName(String name) Sets a single media format to resolve to.@NotNull MediaArgsmediaFormatNames(@NotNull String @Nullable ... names) Sets list of media formats to resolve to.@NotNull MediaArgsmediaFormatOptions(@NotNull MediaArgs.MediaFormatOption @Nullable ... values) Sets list of media formats to resolve to.@NotNull MediaArgsmediaFormats(@Nullable MediaFormat @Nullable ... values) Sets list of media formats to resolve to.@NotNull MediaArgsmediaFormatsMandatory(boolean value) The "mandatory" flag of all media format options is set to to the given value.@NotNull MediaArgspictureSources(@NotNull MediaArgs.PictureSource @Nullable ... value) Set picture sources for responsive image handling.@NotNull MediaArgsproperties(@NotNull Map<String, Object> map) Custom properties that my be used by application-specific markup builders or processors.@NotNull MediaArgsCustom properties that my be used by application-specific markup builders or processors.toString()@NotNull MediaArgsurlMode(@Nullable io.wcm.handler.url.UrlMode value) Set URL mode.@NotNull MediaArgsvideoManifestFormat(@Nullable String value) Set the preferred video manifest format.@NotNull MediaArgswebOptimizedImageDeliveryDisabled(boolean value) Set whether web-optimized image delivery is disabled.
-
Constructor Details
-
MediaArgs
public MediaArgs()Default constructor -
MediaArgs
Create media arguments with media formats.- Parameters:
mediaFormats- Media formats
-
MediaArgs
Create media arguments with media format names.- Parameters:
mediaFormatNames- Media format names
-
-
Method Details
-
getMediaFormats
Returns list of media formats to resolve to.- Returns:
- Media formats
-
mediaFormats
@NotNull public @NotNull MediaArgs mediaFormats(@Nullable @Nullable MediaFormat @Nullable ... values) Sets list of media formats to resolve to.- Parameters:
values- Media formats- Returns:
- this
-
mandatoryMediaFormats
@NotNull public @NotNull MediaArgs mandatoryMediaFormats(@NotNull @NotNull MediaFormat @Nullable ... values) Sets list of media formats to resolve to.- Parameters:
values- Media formats- Returns:
- this
-
mediaFormat
Sets a single media format to resolve to.- Parameters:
value- Media format- Returns:
- this
-
mediaFormatsMandatory
The "mandatory" flag of all media format options is set to to the given value.- Parameters:
value- Resolving of all media formats is mandatory.- Returns:
- this
-
getMediaFormatNames
Returns list of media formats to resolve to. SeegetMediaFormatNames()for details.- Returns:
- Media format names
-
mediaFormatNames
Sets list of media formats to resolve to.- Parameters:
names- Media format names.- Returns:
- this
-
mandatoryMediaFormatNames
@NotNull public @NotNull MediaArgs mandatoryMediaFormatNames(@NotNull @NotNull String @Nullable ... names) Sets list of media formats to resolve to.- Parameters:
names- Media format names.- Returns:
- this
-
mediaFormatName
Sets a single media format to resolve to.- Parameters:
name- Media format name- Returns:
- this
-
getMediaFormatOptions
Gets list of media formats to resolve to.- Returns:
- Media formats with mandatory flag
-
mediaFormatOptions
@NotNull public @NotNull MediaArgs mediaFormatOptions(@NotNull @NotNull MediaArgs.MediaFormatOption @Nullable ... values) Sets list of media formats to resolve to.- Parameters:
values- Media formats with mandatory flag- Returns:
- this
-
isAutoCrop
public boolean isAutoCrop()Check if auto-cropping mode is enabled.- Returns:
- Enables "auto-cropping" mode. If no matching rendition is found it is tried to generate one by automatically cropping another one.
-
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
-
getFileExtensions
Get accepted file extensions.- Returns:
- Accepted file extensions
-
fileExtensions
Set accepted file extensions.- Parameters:
values- Accepted file extensions- Returns:
- this
-
fileExtension
Set accepted file extension.- Parameters:
value- Accepted file extension- Returns:
- this
-
getEnforceOutputFileExtension
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
- Returns:
- File extension to be used for returned renditions
-
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
-
getUrlMode
@Nullable public @Nullable io.wcm.handler.url.UrlMode getUrlMode()Get URL mode.- Returns:
- URL mode
-
urlMode
Set URL mode.- Parameters:
value- URS mode- Returns:
- this
-
getFixedWidth
public long getFixedWidth()Use fixed width instead of width from media format or original image- Returns:
- Fixed width
-
fixedWidth
Use fixed width instead of width from media format or original image- Parameters:
value- Fixed width- Returns:
- this
-
getFixedHeight
public long getFixedHeight()Use fixed height instead of width from media format or original image- Returns:
- Fixed height
-
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
-
isDownload
public boolean isDownload()Check if only download media formats are accepted.- Returns:
- Accept only media formats that have the download flag set.
-
download
Set whether to accept only download media formats.- Parameters:
value- Accept only media formats that have the download flag set.- Returns:
- this
-
isContentDispositionAttachment
public boolean isContentDispositionAttachment()Check if Content-Disposition header should be set to attachment.- Returns:
- Whether to set a "Content-Disposition" header to "attachment" for forcing a "Save as" dialog on the client
-
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
-
getAltText
Get custom alternative text.- Returns:
- The custom alternative text that is to be used instead of the one defined in the the asset metadata.
-
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
-
isForceAltValueFromAsset
public boolean isForceAltValueFromAsset()Check if alt text should be forced from DAM asset description.- Returns:
- Whether to force to read alt. text from DAM asset description.
-
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
-
isDecorative
public boolean isDecorative()Check if image is marked as decorative.- Returns:
- Marks this image as "decorative". Alt. text is then explicitly set to an empty string.
-
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
-
isDummyImage
public boolean isDummyImage()Check if dummy image is enabled.- Returns:
- If set to true, media handler never returns a dummy image. Otherwise this can happen in edit mode.
-
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
-
getDummyImageUrl
Get URL of custom dummy image.- Returns:
- Url of custom dummy image. If null default dummy image is used.
-
dummyImageUrl
Set URL of custom dummy image.- Parameters:
value- Url of custom dummy image. If null default dummy image is used.- Returns:
- this
-
getIncludeAssetAemRenditions
Get which types of AEM-generated renditions are included.- Returns:
- Defines which types of AEM-generated renditions (with
cq5dam.prefix) are taken into account when trying to resolve the media request.
-
includeAssetAemRenditions
@NotNull public @NotNull MediaArgs includeAssetAemRenditions(@Nullable @Nullable 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
-
isIncludeAssetThumbnails
Deprecated.UseincludeAssetAemRenditions(Set)instead.- Returns:
- If set to true, thumbnail generated by AEM (with
cq5dam.thumbnail.prefix) are taken into account as well when trying to resolve the media request. Defaults to false.
-
includeAssetThumbnails
Deprecated.UseincludeAssetAemRenditions(Set)instead.- Parameters:
value- If set to true, thumbnail generated by AEM (withcq5dam.thumbnail.prefix) are taken into account as well when trying to resolve the media request.- Returns:
- this
-
isIncludeAssetWebRenditions
Deprecated.UseincludeAssetAemRenditions(Set)instead.- Returns:
- If set to true, web renditions generated by AEM (with
cq5dam.web.prefix) are taken into account as well when trying to resolve the media request. If null, the default setting applies from the media handler configuration.
-
includeAssetWebRenditions
@Deprecated(since="2.0.0") @NotNull public @NotNull MediaArgs includeAssetWebRenditions(boolean value) Deprecated.UseincludeAssetAemRenditions(Set)instead.- Parameters:
value- If set to true, web renditions generated by AEM (withcq5dam.web.prefix) are taken into account as well when trying to resolve the media request.- Returns:
- this
-
getImageSizes
Get image sizes for responsive image handling.- Returns:
- Image sizes for responsive image handling
-
imageSizes
Set image sizes for responsive image handling.- Parameters:
value- Image sizes for responsive image handling- Returns:
- this
-
getPictureSources
Get picture sources for responsive image handling.- Returns:
- Picture sources for responsive image handling
-
pictureSources
@NotNull public @NotNull MediaArgs pictureSources(@NotNull @NotNull MediaArgs.PictureSource @Nullable ... value) Set picture sources for responsive image handling.- Parameters:
value- Picture sources for responsive image handling- Returns:
- this
-
isDynamicMediaDisabled
public boolean isDynamicMediaDisabled()Check if dynamic media support is disabled.- Returns:
- If set to true, dynamic media support is disabled even when enabled on the instance.
-
dynamicMediaDisabled
Set whether dynamic media support is disabled.- Parameters:
value- If set to true, dynamic media support is disabled even when enabled on the instance.- Returns:
- this
-
isWebOptimizedImageDeliveryDisabled
public boolean isWebOptimizedImageDeliveryDisabled()Check if web-optimized image delivery is disabled.- Returns:
- If set to true, web-optimized image delivery is disabled even when enabled on the instance.
-
webOptimizedImageDeliveryDisabled
Set whether web-optimized image delivery is disabled.- Parameters:
value- If set to true, web-optimized image delivery is disabled even when enabled on the instance.- Returns:
- this
-
getImageQualityPercentage
Get image quality percentage.- Returns:
- Image quality in percent (0..1) for images with lossy compression (e.g. JPEG).
-
imageQualityPercentage
Set image quality percentage.- Parameters:
value- Image quality in percent (0..1) for images with lossy compression (e.g. JPEG).- Returns:
- this
-
getDragDropSupport
Drag&Drop support for media builder.- Returns:
- Drag&Drop support
-
dragDropSupport
Drag&Drop support for media builder.- Parameters:
value- Drag&Drop support- Returns:
- this
-
getIPERatioCustomize
Get IPE ratio customization setting.- Returns:
- Whether to set customized list of IPE cropping ratios.
-
ipeRatioCustomize
Set IPE ratio customization setting.- Parameters:
value- Whether to set customized list of IPE cropping ratios.- Returns:
- this
-
getVideoManifestFormat
Get the preferred video manifest format.- Returns:
- Preferred video manifest format
-
videoManifestFormat
Set the preferred video manifest format.- Parameters:
value- Preferred video manifest format as file extension string (e.g.MediaFileType.M3U8.getExtension()for HLS,MediaFileType.MPD.getExtension()for DASH)- Returns:
- this
-
isHostedVideoPlayer
public boolean isHostedVideoPlayer()Check if hosted video player is enabled.- Returns:
- Whether to use Adobe's hosted video player instead of a streaming manifest, affecting both URL generation and markup (iframe vs. HTML5 video element).
-
hostedVideoPlayer
Set whether to 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
-
properties
Custom properties that my be used by application-specific markup builders or processors.- Parameters:
map- Property map. Is merged with properties already set.- Returns:
- this
-
property
@NotNull public @NotNull MediaArgs property(@NotNull @NotNull String key, @Nullable @Nullable Object value) Custom properties that my be used by application-specific markup builders or processors.- Parameters:
key- Property keyvalue- Property value- Returns:
- this
-
getProperties
@NotNull public @NotNull org.apache.sling.api.resource.ValueMap getProperties()Custom properties that my be used by application-specific markup builders or processors.- Returns:
- Value map
-
hashCode
public int hashCode() -
equals
-
toString
-
clone
Custom clone-method forMediaArgs
-
includeAssetAemRenditions(Set)instead.