Package io.wcm.handler.media
Class MediaArgs
- java.lang.Object
-
- io.wcm.handler.media.MediaArgs
-
- All Implemented Interfaces:
java.lang.Cloneable
@ProviderType public final class MediaArgs extends java.lang.Object implements java.lang.CloneableHolds parameters to influence the media resolving process.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMediaArgs.ImageSizesImage sizes for responsive image handling.static classMediaArgs.MediaFormatOptionMedia format to be applied on media processing.static classMediaArgs.PictureSourcePicture source for responsive image handling.static classMediaArgs.WidthOptionWidth value with mandatory flag.
-
Constructor Summary
Constructors Constructor Description MediaArgs()Default constructorMediaArgs(@NotNull MediaFormat @NotNull ... mediaFormats)MediaArgs(@NotNull java.lang.String @NotNull ... mediaFormatNames)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description @NotNull MediaArgsaltText(@Nullable java.lang.String value)Allows 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)MediaArgsclone()Custom clone-method forMediaArgs@NotNull MediaArgscontentDispositionAttachment(boolean value)@NotNull MediaArgsdecorative(boolean value)@NotNull MediaArgsdownload(boolean value)@NotNull MediaArgsdragDropSupport(@NotNull DragDropSupport value)Drag&Drop support for media builder.@NotNull MediaArgsdummyImage(boolean value)@NotNull MediaArgsdummyImageUrl(@Nullable java.lang.String value)@NotNull MediaArgsdynamicMediaDisabled(boolean value)@NotNull MediaArgsenforceOutputFileExtension(@Nullable java.lang.String value)Enforces image file type for renditions.booleanequals(java.lang.Object obj)@NotNull MediaArgsfileExtension(@Nullable java.lang.String value)@NotNull MediaArgsfileExtensions(@NotNull java.lang.String @Nullable ... values)@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)@Nullable java.lang.StringgetAltText()@NotNull DragDropSupportgetDragDropSupport()Drag&Drop support for media builder.@Nullable java.lang.StringgetDummyImageUrl()@Nullable java.lang.StringgetEnforceOutputFileExtension()Enforces image file type for renditions.java.lang.String @Nullable []getFileExtensions()longgetFixedHeight()Use fixed height instead of width from media format or original imagelonggetFixedWidth()Use fixed width instead of width from media format or original image@Nullable java.lang.DoublegetImageQualityPercentage()@Nullable MediaArgs.ImageSizesgetImageSizes()@Nullable java.util.Set<AemRenditionType>getIncludeAssetAemRenditions()IPERatioCustomizegetIPERatioCustomize()java.lang.String @Nullable []getMediaFormatNames()Returns list of media formats to resolve to.MediaArgs.MediaFormatOption @Nullable []getMediaFormatOptions()Gets list of media formats to resolve to.MediaFormat @Nullable []getMediaFormats()Returns list of media formats to resolve to.MediaArgs.PictureSource @Nullable []getPictureSources()@NotNull org.apache.sling.api.resource.ValueMapgetProperties()Custom properties that my be used by application-specific markup builders or processors.@Nullable io.wcm.handler.url.UrlModegetUrlMode()inthashCode()@NotNull MediaArgsimageQualityPercentage(@Nullable java.lang.Double value)@NotNull MediaArgsimageSizes(@Nullable MediaArgs.ImageSizes value)@NotNull MediaArgsincludeAssetAemRenditions(@Nullable java.util.Set<AemRenditionType> value)@NotNull MediaArgsincludeAssetThumbnails(boolean value)Deprecated.UseincludeAssetAemRenditions(Set)instead.@NotNull MediaArgsincludeAssetWebRenditions(boolean value)Deprecated.UseincludeAssetAemRenditions(Set)instead.@NotNull MediaArgsipeRatioCustomize(@Nullable IPERatioCustomize value)booleanisAutoCrop()booleanisContentDispositionAttachment()booleanisDecorative()booleanisDownload()booleanisDummyImage()booleanisDynamicMediaDisabled()booleanisForceAltValueFromAsset()@Nullable java.lang.BooleanisIncludeAssetThumbnails()Deprecated.UseincludeAssetAemRenditions(Set)instead.@Nullable java.lang.BooleanisIncludeAssetWebRenditions()Deprecated.UseincludeAssetAemRenditions(Set)instead.booleanisWebOptimizedImageDeliveryDisabled()@NotNull MediaArgsmandatoryMediaFormatNames(@NotNull java.lang.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(java.lang.String name)Sets a single media format to resolve to.@NotNull MediaArgsmediaFormatNames(@NotNull java.lang.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)@NotNull MediaArgsproperties(@NotNull java.util.Map<java.lang.String,java.lang.Object> map)Custom properties that my be used by application-specific markup builders or processors.@NotNull MediaArgsproperty(@NotNull java.lang.String key, @Nullable java.lang.Object value)Custom properties that my be used by application-specific markup builders or processors.java.lang.StringtoString()@NotNull MediaArgsurlMode(@Nullable io.wcm.handler.url.UrlMode value)@NotNull MediaArgswebOptimizedImageDeliveryDisabled(boolean value)
-
-
-
Constructor Detail
-
MediaArgs
public MediaArgs()
Default constructor
-
MediaArgs
public MediaArgs(@NotNull @NotNull MediaFormat @NotNull ... mediaFormats)- Parameters:
mediaFormats- Media formats
-
MediaArgs
public MediaArgs(@NotNull @NotNull java.lang.String @NotNull ... mediaFormatNames)- Parameters:
mediaFormatNames- Media format names
-
-
Method Detail
-
getMediaFormats
public MediaFormat @Nullable [] 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
@NotNull public @NotNull MediaArgs mediaFormat(MediaFormat value)
Sets a single media format to resolve to.- Parameters:
value- Media format- Returns:
- this
-
mediaFormatsMandatory
@NotNull public @NotNull MediaArgs mediaFormatsMandatory(boolean value)
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
public java.lang.String @Nullable [] getMediaFormatNames()
Returns list of media formats to resolve to. SeegetMediaFormatNames()for details.- Returns:
- Media format names
-
mediaFormatNames
@NotNull public @NotNull MediaArgs mediaFormatNames(@NotNull @NotNull java.lang.String @Nullable ... names)
Sets list of media formats to resolve to.- Parameters:
names- Media format names.- Returns:
- this
-
mandatoryMediaFormatNames
@NotNull public @NotNull MediaArgs mandatoryMediaFormatNames(@NotNull @NotNull java.lang.String @Nullable ... names)
Sets list of media formats to resolve to.- Parameters:
names- Media format names.- Returns:
- this
-
mediaFormatName
@NotNull public @NotNull MediaArgs mediaFormatName(java.lang.String name)
Sets a single media format to resolve to.- Parameters:
name- Media format name- Returns:
- this
-
getMediaFormatOptions
public MediaArgs.MediaFormatOption @Nullable [] 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()
- Returns:
- Enables "auto-cropping" mode. If no matching rendition is found it is tried to generate one by automatically cropping another one.
-
autoCrop
@NotNull public @NotNull MediaArgs autoCrop(boolean value)
- 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
public java.lang.String @Nullable [] getFileExtensions()
- Returns:
- Accepted file extensions
-
fileExtensions
@NotNull public @NotNull MediaArgs fileExtensions(@NotNull @NotNull java.lang.String @Nullable ... values)
- Parameters:
values- Accepted file extensions- Returns:
- this
-
fileExtension
@NotNull public @NotNull MediaArgs fileExtension(@Nullable @Nullable java.lang.String value)
- Parameters:
value- Accepted file extension- Returns:
- this
-
getEnforceOutputFileExtension
@Nullable public @Nullable java.lang.String 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
@NotNull public @NotNull MediaArgs enforceOutputFileExtension(@Nullable @Nullable java.lang.String value)
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()
- Returns:
- URL mode
-
urlMode
@NotNull public @NotNull MediaArgs urlMode(@Nullable @Nullable io.wcm.handler.url.UrlMode value)
- 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
@NotNull public @NotNull MediaArgs fixedWidth(long value)
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
@NotNull public @NotNull MediaArgs fixedHeight(long value)
Use fixed height instead of width from media format or original image- Parameters:
value- Fixed height- Returns:
- this
-
fixedDimension
@NotNull public @NotNull MediaArgs fixedDimension(long widthValue, long heightValue)
Use fixed dimensions instead of width from media format or original image- Parameters:
widthValue- Fixed widthheightValue- Fixed height- Returns:
- this
-
isDownload
public boolean isDownload()
- Returns:
- Accept only media formats that have the download flag set.
-
download
@NotNull public @NotNull MediaArgs download(boolean value)
- Parameters:
value- Accept only media formats that have the download flag set.- Returns:
- this
-
isContentDispositionAttachment
public boolean isContentDispositionAttachment()
- Returns:
- Whether to set a "Content-Disposition" header to "attachment" for forcing a "Save as" dialog on the client
-
contentDispositionAttachment
@NotNull public @NotNull MediaArgs contentDispositionAttachment(boolean value)
- Parameters:
value- Whether to set a "Content-Disposition" header to "attachment" for forcing a "Save as" dialog on the client- Returns:
- this
-
getAltText
@Nullable public @Nullable java.lang.String getAltText()
- Returns:
- The custom alternative text that is to be used instead of the one defined in the the asset metadata.
-
altText
@NotNull public @NotNull MediaArgs altText(@Nullable @Nullable java.lang.String value)
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()
- Returns:
- Whether to force to read alt. text from DAM asset description.
-
forceAltValueFromAsset
@NotNull public @NotNull MediaArgs forceAltValueFromAsset(boolean value)
- 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()
- Returns:
- Marks this image as "decorative". Alt. text is then explicitly set to an empty string.
-
decorative
@NotNull public @NotNull MediaArgs decorative(boolean value)
- Parameters:
value- Marks this image as "decorative". Alt. text is then explicitly set to an empty string.- Returns:
- this
-
isDummyImage
public boolean isDummyImage()
- Returns:
- If set to true, media handler never returns a dummy image. Otherwise this can happen in edit mode.
-
dummyImage
@NotNull public @NotNull MediaArgs dummyImage(boolean value)
- Parameters:
value- If set to false, media handler never returns a dummy image. Otherwise this can happen in edit mode.- Returns:
- this
-
getDummyImageUrl
@Nullable public @Nullable java.lang.String getDummyImageUrl()
- Returns:
- Url of custom dummy image. If null default dummy image is used.
-
dummyImageUrl
@NotNull public @NotNull MediaArgs dummyImageUrl(@Nullable @Nullable java.lang.String value)
- Parameters:
value- Url of custom dummy image. If null default dummy image is used.- Returns:
- this
-
getIncludeAssetAemRenditions
@Nullable public @Nullable java.util.Set<AemRenditionType> getIncludeAssetAemRenditions()
- 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 java.util.Set<AemRenditionType> value)
- 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(since="2.0.0") @Nullable public @Nullable java.lang.Boolean 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(since="2.0.0") @NotNull public @NotNull MediaArgs includeAssetThumbnails(boolean value)
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(since="2.0.0") @Nullable public @Nullable java.lang.Boolean 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
@Nullable public @Nullable MediaArgs.ImageSizes getImageSizes()
- Returns:
- Image sizes for responsive image handling
-
imageSizes
@NotNull public @NotNull MediaArgs imageSizes(@Nullable @Nullable MediaArgs.ImageSizes value)
- Parameters:
value- Image sizes for responsive image handling- Returns:
- this
-
getPictureSources
public MediaArgs.PictureSource @Nullable [] getPictureSources()
- Returns:
- Picture sources for responsive image handling
-
pictureSources
@NotNull public @NotNull MediaArgs pictureSources(@NotNull @NotNull MediaArgs.PictureSource @Nullable ... value)
- Parameters:
value- Picture sources for responsive image handling- Returns:
- this
-
isDynamicMediaDisabled
public boolean isDynamicMediaDisabled()
- Returns:
- If set to true, dynamic media support is disabled even when enabled on the instance.
-
dynamicMediaDisabled
@NotNull public @NotNull MediaArgs dynamicMediaDisabled(boolean value)
- Parameters:
value- If set to true, dynamic media support is disabled even when enabled on the instance.- Returns:
- this
-
isWebOptimizedImageDeliveryDisabled
public boolean isWebOptimizedImageDeliveryDisabled()
- Returns:
- If set to true, web-optimized image delivery is disabled even when enabled on the instance.
-
webOptimizedImageDeliveryDisabled
@NotNull public @NotNull MediaArgs webOptimizedImageDeliveryDisabled(boolean value)
- Parameters:
value- If set to true, web-optimized image delivery is disabled even when enabled on the instance.- Returns:
- this
-
getImageQualityPercentage
@Nullable public @Nullable java.lang.Double getImageQualityPercentage()
- Returns:
- Image quality in percent (0..1) for images with lossy compression (e.g. JPEG).
-
imageQualityPercentage
@NotNull public @NotNull MediaArgs imageQualityPercentage(@Nullable @Nullable java.lang.Double value)
- Parameters:
value- Image quality in percent (0..1) for images with lossy compression (e.g. JPEG).- Returns:
- this
-
getDragDropSupport
@NotNull public @NotNull DragDropSupport getDragDropSupport()
Drag&Drop support for media builder.- Returns:
- Drag&Drop support
-
dragDropSupport
@NotNull public @NotNull MediaArgs dragDropSupport(@NotNull @NotNull DragDropSupport value)
Drag&Drop support for media builder.- Parameters:
value- Drag&Drop support- Returns:
- this
-
getIPERatioCustomize
public IPERatioCustomize getIPERatioCustomize()
- Returns:
- Whether to set customized list of IPE cropping ratios.
-
ipeRatioCustomize
@NotNull public @NotNull MediaArgs ipeRatioCustomize(@Nullable @Nullable IPERatioCustomize value)
- Parameters:
value- Whether to set customized list of IPE cropping ratios.- Returns:
- this
-
properties
@NotNull public @NotNull MediaArgs properties(@NotNull @NotNull java.util.Map<java.lang.String,java.lang.Object> map)
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 java.lang.String key, @Nullable @Nullable java.lang.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()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-