Class MediaArgs

  • All Implemented Interfaces:
    Cloneable

    @ProviderType
    public final class MediaArgs
    extends Object
    implements Cloneable
    Holds parameters to influence the media resolving process.
    • Constructor Detail

      • MediaArgs

        public MediaArgs()
        Default constructor
      • MediaArgs

        public MediaArgs​(@NotNull
                         @NotNull MediaFormat @NotNull ... mediaFormats)
        Parameters:
        mediaFormats - Media formats
      • MediaArgs

        public MediaArgs​(@NotNull
                         @NotNull String @NotNull ... mediaFormatNames)
        Parameters:
        mediaFormatNames - Media format names
    • Method Detail

      • getMediaFormats

        public MediaFormat[] getMediaFormats()
        Returns list of media formats to resolve to. If isMediaFormatsMandatory() is false, the first rendition that matches any of the given media format is returned. If it is set to true, for each media format given a rendition has to be resolved and returned. If not all renditions could be resolved the media is marked as invalid (but the partial resolved renditions are returned anyway).
        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. Additionally isMediaFormatsMandatory() is set to true.
        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
      • isMediaFormatsMandatory

        @Deprecated
        public boolean isMediaFormatsMandatory()
        Deprecated.
        Please check the mandatory flag for each media format individually via getMediaFormatOptions()
        Checks if all media format options have the "mandatory" flag set. If none or not all of them have the flag set, false is returned.
        Returns:
        true if all media format options have the "mandatory" flag set.
      • 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 String[] getMediaFormatNames()
        Returns list of media formats to resolve to. See getMediaFormatNames() for details.
        Returns:
        Media format names
      • mediaFormatNames

        @NotNull
        public @NotNull MediaArgs mediaFormatNames​(@NotNull
                                                   @NotNull 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 String @Nullable ... names)
        Sets list of media formats to resolve to. Additionally isMediaFormatsMandatory() is set to true.
        Parameters:
        names - Media format names.
        Returns:
        this
      • mediaFormatName

        @NotNull
        public @NotNull MediaArgs mediaFormatName​(String name)
        Sets a single media format to resolve to.
        Parameters:
        name - Media format name
        Returns:
        this
      • getMediaFormatOptions

        public MediaArgs.MediaFormatOption[] 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 String[] getFileExtensions()
        Returns:
        File extensions
      • fileExtensions

        @NotNull
        public @NotNull MediaArgs fileExtensions​(@NotNull
                                                 @NotNull String @Nullable ... values)
        Parameters:
        values - File extensions
        Returns:
        this
      • fileExtension

        @NotNull
        public @NotNull MediaArgs fileExtension​(String value)
        Parameters:
        value - File extension
        Returns:
        this
      • getUrlMode

        public io.wcm.handler.url.UrlMode getUrlMode()
        Returns:
        URL mode
      • urlMode

        @NotNull
        public @NotNull MediaArgs urlMode​(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 width
        heightValue - 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

        public String getAltText()
        Returns:
        The custom alternative text that is to be used instead of the one defined in the the media lib item
      • altText

        @NotNull
        public @NotNull MediaArgs altText​(String value)
        Allows to specify a custom alternative text that is to be used instead of the one defined in the the media lib item
        Parameters:
        value - Custom alternative text. If null or empty, the default alt text from media library is used.
        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

        public String getDummyImageUrl()
        Returns:
        Url of custom dummy image. If null default dummy image is used.
      • dummyImageUrl

        @NotNull
        public @NotNull MediaArgs dummyImageUrl​(String value)
        Parameters:
        value - Url of custom dummy image. If null default dummy image is used.
        Returns:
        this
      • isIncludeAssetThumbnails

        public boolean isIncludeAssetThumbnails()
        Returns:
        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.
      • includeAssetThumbnails

        @NotNull
        public @NotNull MediaArgs includeAssetThumbnails​(boolean value)
        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:
        this
      • isIncludeAssetWebRenditions

        public Boolean isIncludeAssetWebRenditions()
        Returns:
        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. If null, the default setting applies from the media handler configuration.
      • includeAssetWebRenditions

        @NotNull
        public @NotNull MediaArgs includeAssetWebRenditions​(boolean value)
        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:
        this
      • getImageSizes

        public MediaArgs.ImageSizes getImageSizes()
        Returns:
        Image sizes for responsive image handling
      • imageSizes

        @NotNull
        public @NotNull MediaArgs imageSizes​(MediaArgs.ImageSizes value)
        Parameters:
        value - Image sizes for responsive image handling
        Returns:
        this
      • getPictureSources

        public MediaArgs.PictureSource[] 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
      • getDragDropSupport

        public DragDropSupport getDragDropSupport()
        Drag&Drop support for media builder.
        Returns:
        Drag&Drop support
      • dragDropSupport

        @NotNull
        public @NotNull MediaArgs dragDropSupport​(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​(IPERatioCustomize value)
        Parameters:
        value - Whether to set customized list of IPE cropping ratios.
        Returns:
        this
      • properties

        @NotNull
        public @NotNull MediaArgs properties​(Map<String,​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​(String key,
                                           Object value)
        Custom properties that my be used by application-specific markup builders or processors.
        Parameters:
        key - Property key
        value - 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:
        hashCode in class Object