Class MediaFormat

  • All Implemented Interfaces:
    java.lang.Comparable<MediaFormat>

    @ProviderType
    public final class MediaFormat
    extends java.lang.Object
    implements java.lang.Comparable<MediaFormat>
    Media format.
    • Method Detail

      • getName

        @NotNull
        public @NotNull java.lang.String getName()
        Returns:
        Media format name
      • getLabel

        @NotNull
        public @NotNull java.lang.String getLabel()
        Returns:
        Media format label
      • getDescription

        @Nullable
        public @Nullable java.lang.String getDescription()
        Returns:
        Media format description
      • getWidth

        public long getWidth()
        Returns:
        Image width (px)
      • getMinWidth

        public long getMinWidth()
        Returns:
        Min. image width (px)
      • getMaxWidth

        public long getMaxWidth()
        Returns:
        Max. image width (px)
      • getHeight

        public long getHeight()
        Returns:
        Image height (px)
      • getMinHeight

        public long getMinHeight()
        Returns:
        Min. image height (px)
      • getMaxHeight

        public long getMaxHeight()
        Returns:
        Max. image height (px)
      • getMinWidthHeight

        public long getMinWidthHeight()
        Returns:
        Min. width/height (px) - the longest edge is checked. Cannot be combined with other width/height restrictions.
      • getRatioWidthAsDouble

        public double getRatioWidthAsDouble()
        Returns:
        Ration width (px)
      • getRatioHeightAsDouble

        public double getRatioHeightAsDouble()
        Returns:
        Ration height (px)
      • getRatio

        public double getRatio()
        Returns the ratio defined in the media format definition. If no ratio is defined an the media format has a fixed width/height it is calculated automatically. Otherwise 0 is returned.
        Returns:
        Ratio
      • getRatioDisplayString

        public java.lang.String getRatioDisplayString()
        Return display string for defined ratio.
        Returns:
        Display string or null if media format has no ratio.
      • hasRatio

        public boolean hasRatio()
        Returns:
        true if the media format has ratio (calculated for fixed dimensions or defined in media format)
      • getFileSizeMax

        public long getFileSizeMax()
        Returns:
        Max. file size (bytes)
      • getExtensions

        public java.lang.String[] getExtensions()
        Returns:
        Allowed file extensions
      • getRenditionGroup

        public java.lang.String getRenditionGroup()
        Returns:
        Rendition group id
      • isDownload

        public boolean isDownload()
        Returns:
        Media assets with this format should be downloaded and not displayed directly
      • isInternal

        public boolean isInternal()
        Returns:
        For internal use only (not displayed for user)
      • getRanking

        public long getRanking()
        Returns:
        Ranking for auto-detection. Lowest value = highest priority.
      • isImage

        public boolean isImage()
        Returns:
        Whether the format allows at least one image extension
      • isFixedWidth

        public boolean isFixedWidth()
        Checks if the media format has a fixed width defined, and no min/max constraints.
        Returns:
        If the media format has a fixed dimension.
      • isFixedHeight

        public boolean isFixedHeight()
        Checks if the media format has a fixed height defined, and no min/max constraints.
        Returns:
        If the media format has a fixed dimension.
      • isFixedDimension

        public boolean isFixedDimension()
        Checks if the media format has a fixed width and height defined, and no min/max constraints.
        Returns:
        If the media format has a fixed dimension.
      • getEffectiveMinWidth

        public long getEffectiveMinWidth()
        Returns:
        Effective min. image width (px). Takes widthMin and width into account.
      • getEffectiveMaxWidth

        public long getEffectiveMaxWidth()
        Returns:
        Effective max. image width (px). Takes widthMax and width into account.
      • getEffectiveMinHeight

        public long getEffectiveMinHeight()
        Returns:
        Effective min. image height (px). Takes heightMin and height into account.
      • getEffectiveMaxHeight

        public long getEffectiveMaxHeight()
        Returns:
        Effective max. image height (px). Takes heightMax and height into account.
      • getMinDimension

        public Dimension getMinDimension()
        Get minimum dimensions for media format. If only width or height is defined the missing dimensions is calculated from the ratio. If no ratio defined either only width or height dimension is returned. If neither width or height are defined null is returned.
        Returns:
        Min. dimensions or null
      • getProperties

        public org.apache.sling.api.resource.ValueMap getProperties()
        Returns:
        Custom properties that my be used by application-specific markup builders or processors.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
        Returns:
        User-friendly combined title of current media format name and dimension.
      • equals

        public boolean equals​(java.lang.Object pObj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • compareTo

        public int compareTo​(MediaFormat o)
        Specified by:
        compareTo in interface java.lang.Comparable<MediaFormat>