public class CmsJspTagScaleImage extends CmsJspImageScalerTagSupport
No output is generated by this tag!
Instead the tag generates a CmsJspImageBean.
This can be used to further process the selected image
with the provided image scaling parameters.
The following image formats are supported: BMP, GIF, JPEG, PNG, PNM, TIFF.
Note: Picture scaling is by default only enabled for target size with width and height
<=1500. The size can be changed in the image scaler configuration in the file
opencms-vfs.xml in the body of the tag <loader>. Also other
options for the image scaler are set there.
This tag is an alternative to the OpenCms standard tag cms:img, providing additional flexibility. This way you can use scaled images for:
Example for a simple JSP that uses this tag to obtain information about an image:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms"%>
<cms:scaleImage var="imgBean" src="/.galleries/samples/09.jpg?__scale=h:385,w:961,cx:42,cy:32,ch:385,cw:961" />
srcUrl: <c:out value="${imgBean.srcUrl}" /><br>
vfsUri: <c:out value="${imgBean.vfsUri}" /><br>
scalerParams: <c:out value="${imgBean.scaler.requestParam}" /><br>
Width: <c:out value="${imgBean.width}" /><br>
Height: <c:out value="${imgBean.height}" /><br>
scaledWidth: <c:out value="${imgBean.scaler.width}" /><br>
scaledHeight: <c:out value="${imgBean.scaler.height}" /><br>
isScaled: <c:out value="${imgBean.scaled}" /><br>
m_scaler, m_src, SCALE_ATTR_HEIGHT, SCALE_ATTR_MAXHEIGHT, SCALE_ATTR_MAXWIDTH, SCALE_ATTR_POSITION, SCALE_ATTR_QUALITY, SCALE_ATTR_RENDERMODE, SCALE_ATTR_TYPE, SCALE_ATTR_WIDTH| Constructor and Description |
|---|
CmsJspTagScaleImage()
Creates a new image scaling tag instance.
|
| Modifier and Type | Method and Description |
|---|---|
int |
doEndTag()
Does some cleanup before returning EVAL_PAGE
|
int |
doStartTag()
Handles the Start tag, checks some parameters, uses the CmsImageScaler to create a scaled
version of the image (and hi-DPI variants if necessary), stores all information in a
image bean and stores it as a request attribute (the name for this attribute is given
with the tag attribute "var").
|
static CmsJspImageBean |
imageTagAction(CmsObject cms,
java.lang.String imageUri,
CmsImageScaler targetScaler,
java.util.List<java.lang.String> hiDpiVariantList)
Internal action method to create the scaled image bean.
|
void |
release()
Does some cleanup before the tag is released to the tag pool
|
void |
setHiDpiVariants(java.lang.String value)
Sets the String containing a comma separated list of hi-DPI variants to produce line "1.3x,1.5x,2x,3x".
|
void |
setVar(java.lang.String value)
Sets the name of the variable used for storing the resulting bean.
|
getHeight, getMaxHeight, getMaxWidth, getScaleColor, getScaleFilter, getScalePosition, getScaleQuality, getScaleRendermode, getScaleType, getSrc, getWidth, setHeight, setMaxHeight, setMaxWidth, setScaleColor, setScaleFilter, setScalePosition, setScaleQuality, setScaleRendermode, setScaleType, setSrc, setWidthdoAfterBody, doInitBody, getBodyContent, getPreviousOut, setBodyContentfindAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, setPageContext, setParent, setValuepublic CmsJspTagScaleImage()
public static CmsJspImageBean imageTagAction(CmsObject cms, java.lang.String imageUri, CmsImageScaler targetScaler, java.util.List<java.lang.String> hiDpiVariantList) throws CmsException
cms - the cms contextimageUri - the image URItargetScaler - the target image scalerhiDpiVariantList - optional list of hi-DPI variant sizes to produce, e.g. 1.3x, 1.5x, 2x, 3xCmsException - in case something goes wrongpublic int doEndTag() throws javax.servlet.jsp.JspException
doEndTag in interface javax.servlet.jsp.tagext.TagdoEndTag in class javax.servlet.jsp.tagext.BodyTagSupportjavax.servlet.jsp.JspExceptionTag.doEndTag()public int doStartTag()
doStartTag in interface javax.servlet.jsp.tagext.TagdoStartTag in class javax.servlet.jsp.tagext.BodyTagSupportpublic void release()
release in interface javax.servlet.jsp.tagext.Tagrelease in class CmsJspImageScalerTagSupportTag.release()public void setHiDpiVariants(java.lang.String value)
Currently in most cases "2x" should suffice to generate an additiona image for retina screens. Please note that since 11.0 the variants are created by lazy initialization, so there is usually no need to use this.
value - comma separated list of hi-DPI variants to produce, e.g. "1.3x,1.5x,2x,3x"public void setVar(java.lang.String value)
value - name of the resulting CmsJspScaledImage bean