Package io.wcm.handler.media.ui
Class ResourceMedia
- java.lang.Object
-
- io.wcm.handler.media.ui.ResourceMedia
-
@Model(adaptables=org.apache.sling.api.SlingHttpServletRequest.class) public class ResourceMedia extends java.lang.Object
Generic resource-based media model.Optional use parameters when referencing model from Sightly template:
mediaFormat
: Media format name to restrict the allowed media itemsrefProperty
: Name of the property from which the media reference path is read, or node name for inline media.cropProperty
: Name of the property which contains the cropping parametersrotationProperty
: Name of the property which contains the rotation parametercssClass
: CSS classes to be applied on the generated media element (most cases img element)autoCrop
: Sets the auto cropping behavior of the media handler. This will override the component property "wcmio:mediaCropAuto".imageWidths
: Responsive rendition widths for image. Example: "2560?,1920,?1280,640,320".
Appending the suffix "?" makes the width optional, eg. "1440?"
Use always 'imageWidths' together with 'imageSizes' property.
Cannot be used together with the picture source parameters.imageSizes
: "Sizes" string for img element. Example: "(min-width: 400px) 400px, 100vw".
Cannot be used together with the picture source parameters.pictureSourceMediaFormat
: List of media formats for the picture source elements. Example: "['mf_16_9']"
You have to define the same number of array items in all pictureSource* properties.
Cannot be used together with image sizes.pictureSourceMedia
: List of media expressions for the picture source elements. Example: "['(max-width: 799px)', '(min-width: 800px)']"
You have to define the same number of array items in all pictureSource* properties.
Cannot be used together with image sizes.pictureSourceWidths
: List of widths for the picture source elements. Example: "479,719,959,1279,1439?,1440?".
Appending the suffix "?" makes the width optional, eg. "1440?"
You have to define the same number of array items in all pictureSource* properties.
Cannot be used together with image sizes.property:<propertyname>
: Custom properties for MediaArgs can be added with the name prefix "property:", e.g. "property:myprop1"="value1" which adds property "myprop1" to the the MediaArgs. Custom properties with null value will be ignored.
-
-
Constructor Summary
Constructors Constructor Description ResourceMedia()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @Nullable java.lang.String
getMarkup()
Returns the XHTML markup for the resolved media object (if valid).@NotNull Media
getMetadata()
Returns aMedia
object with the metadata of the resolved media.boolean
isValid()
Returns true if the media was resolved successful.
-
-
-
Method Detail
-
getMetadata
@NotNull public @NotNull Media getMetadata()
Returns aMedia
object with the metadata of the resolved media. Result is never null, check for validness with theMedia.isValid()
method.- Returns:
- Media
-
isValid
public boolean isValid()
Returns true if the media was resolved successful.- Returns:
- Media is valid
-
getMarkup
@Nullable public @Nullable java.lang.String getMarkup()
Returns the XHTML markup for the resolved media object (if valid). This is in most cases an img element, but may also contain other arbitrary markup.- Returns:
- Media markup
-
-