Package com.day.cq.wcm.foundation
Class Image
java.lang.Object
org.apache.sling.api.resource.ResourceWrapper
com.day.cq.commons.DownloadResource
com.day.cq.commons.ImageResource
com.day.cq.wcm.foundation.Image
Provides convenience methods for displaying images.
-
Field Summary
FieldsFields inherited from class com.day.cq.commons.ImageResource
DEFAULT_IMAGE_PATH, PN_ALT, PN_DEFAULT_IMAGE_PATH, PN_HEIGHT, PN_HTML_HEIGHT, PN_HTML_WIDTH, PN_IMAGE_CROP, PN_IMAGE_ROTATE, PN_LINK_URL, PN_MAX_HEIGHT, PN_MAX_WIDTH, PN_MIN_HEIGHT, PN_MIN_WIDTH, PN_WIDTHFields inherited from class com.day.cq.commons.DownloadResource
NN_FILE, PN_DESCRIPTION, PN_FILE_NAME, PN_REFERENCE, PN_TITLEFields inherited from interface org.apache.sling.api.resource.Resource
RESOURCE_TYPE_NON_EXISTING -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns a path to an icon representing the file.booleanReturns the placeholder flag.voidloadStyleData(Style style) Loads several definitions from style.voidSets the drop target id for this image, using the name of the resources as path.voidsetDropTargetId(String id, String classifier) Sets the drop target id for this image.voidsetNoPlaceholder(boolean noPlaceholder) Sets the placeholder flag.Methods inherited from class com.day.cq.commons.ImageResource
crop, draw, getAlt, getCropRect, getData, getDoctype, getExtension, getImageDoctype, getLayer, getRotation, getSrc, getTitle, resize, rotate, setAlt, setDoctype, setExtension, setImageDoctype, setSrcMethods inherited from class com.day.cq.commons.DownloadResource
addAttribute, addCssClass, addQueryParam, get, get, getAttributes, getDescription, getDescription, getFileName, getFileNodePath, getFileReference, getHref, getIconType, getInnerHtml, getItemName, getLastModified, getMimeType, getQuery, getSelector, getString, getSuffix, getTitle, hasContent, init, isTouchAuthoringUIMode, set, setDescription, setFileName, setFileNodePath, setFileReference, setHref, setInnerHtml, setIsInUITouchMode, setItemName, setQuery, setSelector, setSuffix, setTitleMethods inherited from class org.apache.sling.api.resource.ResourceWrapper
adaptTo, getChild, getChildren, getName, getParent, getPath, getResource, getResourceMetadata, getResourceResolver, getResourceSuperType, getResourceType, getValueMap, hasChildren, isResourceType, listChildren, toString
-
Field Details
-
PN_IMAGE_MAP
name of the image map property- See Also:
-
-
Constructor Details
-
Image
Creates a new image based on the given resource. the image properties are considered to 'on' the given resource.- Parameters:
resource- resource of the image- Throws:
IllegalArgumentException- if the given resource is not adaptable to node.
-
Image
Creates a new image based on the given resource. the image properties are considered to 'on' the given resource unlessimageNameis specified. then the respective child resource holds the image properties.- Parameters:
resource- current resourceimageName- name of the image resource- Throws:
IllegalArgumentException- if the given resource is not adaptable to node.
-
-
Method Details
-
setDropTargetId
Sets the drop target id for this image. the id is added as css class to the image attribute. and has the format: ""cq-dd-"{id}-{classifier}"- Parameters:
id- the drop target id as configured in edit config.classifier- optional classifier
-
setDropTargetId
Sets the drop target id for this image, using the name of the resources as path.- Parameters:
id- the drop target id as configured in edit config.
-
hasNoPlaceholder
public boolean hasNoPlaceholder()Returns the placeholder flag.- Returns:
trueif no placeholder for empty content should be drawn.
-
setNoPlaceholder
public void setNoPlaceholder(boolean noPlaceholder) Sets the placeholder flag.- Parameters:
noPlaceholder- iftrueno placeholder for empty content is used.
-
loadStyleData
Loads several definitions from style.Currently, the minimum/maximum width and height are transferred from the given style.
- Parameters:
style- style to load definitions from
-
getIconPath
Returns a path to an icon representing the file. Checks if the component of the resource provides an icon for the respective type.- Overrides:
getIconPathin classDownloadResource- Returns:
- a path to an icon or
null.
-