Interface Rendition

  • All Superinterfaces:
    org.apache.sling.api.adapter.Adaptable, io.wcm.wcm.commons.caching.ModificationDateProvider

    @ProviderType
    public interface Rendition
    extends org.apache.sling.api.adapter.Adaptable, io.wcm.wcm.commons.caching.ModificationDateProvider
    Represents a rendition contained in a Asset which can be rendered. A rendition can be pointing to a binary file stored in the repository, or a virtual rendition that is rendered on the fly if required.
    • Method Detail

      • getUrl

        @Nullable
        @Nullable java.lang.String getUrl()
        Get externalized URL pointing to the rendition.
        Returns:
        Rendition URL
      • getPath

        @Nullable
        @Nullable java.lang.String getPath()
        Returns the internal path of the rendition if stored within the JCR repository. If the rendition is a virtual rendition the path points to the binary from which the virtual rendition is derived from.
        Returns:
        Repository path
      • getFileName

        @Nullable
        @Nullable java.lang.String getFileName()
        Returns:
        File name of the renditions source binary
      • getFileExtension

        @Nullable
        @Nullable java.lang.String getFileExtension()
        Returns:
        File extension of the renditions source binary
      • getFileSize

        long getFileSize()
        Returns:
        File size of the rendition in bytes (or -1 if it is unknown).
      • getMimeType

        @Nullable
        @Nullable java.lang.String getMimeType()
        Returns:
        Mime type of the renditions source binary.
      • getMediaFormat

        @Nullable
        @Nullable MediaFormat getMediaFormat()
        Returns:
        Media format that matches with the resolved rendition. Null if no media format was specified for resolving.
      • getProperties

        @NotNull
        @NotNull org.apache.sling.api.resource.ValueMap getProperties()
        Returns:
        Properties of rendition
      • isImage

        boolean isImage()
        Returns:
        true if the rendition is an image format supported by the media handler.
      • isBrowserImage

        boolean isBrowserImage()
        Returns:
        true if the rendition is a web image file that can be displayed in a browser.
      • isVectorImage

        boolean isVectorImage()
        Returns:
        true if the rendition is a vector image that can be displayed in a browser.
      • isDownload

        boolean isDownload()
        Returns:
        true if the rendition is not and image nor a flash movie.
      • getWidth

        long getWidth()
        Gets the width of this rendition. If it is a virtual rendition the virtual height is returned.
        Returns:
        Height in pixels. Returns 0 if no height information is available.
      • getHeight

        long getHeight()
        Gets the height of this rendition. If it is a virtual rendition the virtual height is returned.
        Returns:
        Height in pixels. Returns 0 if no height information is available.
      • getRatio

        default double getRatio()
        Gets the ratio of the image (width / height).
        Returns:
        Ratio. Returns 0 if no width or height information is available.
      • getModificationDate

        @Nullable
        @Nullable java.util.Date getModificationDate()
        Specified by:
        getModificationDate in interface io.wcm.wcm.commons.caching.ModificationDateProvider
        Returns:
        The date of the last modification
      • isFallback

        boolean isFallback()
        Returns:
        true if this rendition is returned as "fallback" not fully fulfilling the media request. Example: An explicit cropping was given, but it could not be fulfilled. If in this case another rendition is returned that fulfills all other media format restrictions, this flag is set to true.
      • getUriTemplate

        @NotNull
        @NotNull UriTemplate getUriTemplate​(@NotNull
                                            @NotNull UriTemplateType type)
        Generate an URI template for the rendition. The URI template ignores the actual resolution of this rendition and allows to scale the rendition to any size within the maximum range of width/height, keeping the aspect ratio and respecting both the original image and probably configured cropping parameters.
        Parameters:
        type - URI template type. It is not supported to use UriTemplateType.CROP_CENTER.
        Returns:
        URI template
        Throws:
        java.lang.IllegalArgumentException - if UriTemplateType.CROP_CENTER is used
        java.lang.UnsupportedOperationException - if the original rendition is not an image or it is a vector image.