info.magnolia.cms.taglibs.util
Class ScaleImageTag

java.lang.Object
  extended by javax.servlet.jsp.tagext.SimpleTagSupport
      extended by info.magnolia.cms.taglibs.util.BaseImageTag
          extended by info.magnolia.cms.taglibs.util.ScaleImageTag
All Implemented Interfaces:
javax.servlet.jsp.tagext.JspTag, javax.servlet.jsp.tagext.SimpleTag

public class ScaleImageTag
extends BaseImageTag

Creates a scaled copy of an image. The maximum width and height of the images can be specified via the attributes.

If the scaled image with the specified name does not exist in the repository, then this tag will create it and save it. If the scaled image already exists, then it will not be recreated.

The name of the node that contains the original image is set by the attribute 'parentContentNode', and the name of the nodeData for the image is set by the attribute 'parentNodeDataName'. If 'parentContentNode' is null, the local content node is used.

The name of the content node that contains the new scaled image is set by the attribute 'imageContentNodeName'. This node is created under the original image node. This ensures that, if the original images is deleted, so are all the scaled versions.

This tag writes out the handle of the content node that contains the image.

Version:
1.0
Author:
Patrick Janssen, Fabrizio Giustina

Field Summary
 
Fields inherited from class info.magnolia.cms.taglibs.util.BaseImageTag
parentContentNodeName, PROPERTIES_CONTENTTYPE_VALUE
 
Constructor Summary
ScaleImageTag()
           
 
Method Summary
 void cleanUp()
          Set objects to null.
 void doTag()
           
protected  String getFilename()
           
protected  boolean rescale(Content parentContentNode, Content imageContentNode)
          Checks to see if the previously scaled image needs to be rescaled.
 void setAllowOversize(boolean allowOversize)
          Allow resizing images beyond their original dimensions?
 void setImageContentNodeName(String imageContentNodeName)
          The name of the new contentNode that will contain the scaled version of the image.
 void setMaxHeight(int maxHeight)
          The maximum height of the image in pixels.
 void setMaxWidth(int maxWidth)
          The maximum width of the image in pixels.
 void setParentContentNodeName(String parentContentNodeName)
          The name of the content node that contains the image to be copied and scaled.
 void setParentNodeDataName(String parentNodeDataName)
          The name of the data node that contains the image data to be copied and scaled.
 
Methods inherited from class info.magnolia.cms.taglibs.util.BaseImageTag
convertHexToColor, convertHexToRGB, convertToSimpleString, createImageNode, getImageContentNode, getRequest
 
Methods inherited from class javax.servlet.jsp.tagext.SimpleTagSupport
findAncestorWithClass, getJspBody, getJspContext, getParent, setJspBody, setJspContext, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScaleImageTag

public ScaleImageTag()
Method Detail

setMaxHeight

public void setMaxHeight(int maxHeight)
The maximum height of the image in pixels.


setMaxWidth

public void setMaxWidth(int maxWidth)
The maximum width of the image in pixels.


setAllowOversize

public void setAllowOversize(boolean allowOversize)
Allow resizing images beyond their original dimensions?


setParentContentNodeName

public void setParentContentNodeName(String parentContentNodeName)
The name of the content node that contains the image to be copied and scaled.

Overrides:
setParentContentNodeName in class BaseImageTag

setParentNodeDataName

public void setParentNodeDataName(String parentNodeDataName)
The name of the data node that contains the image data to be copied and scaled.


setImageContentNodeName

public void setImageContentNodeName(String imageContentNodeName)
The name of the new contentNode that will contain the scaled version of the image.

Overrides:
setImageContentNodeName in class BaseImageTag

doTag

public void doTag()
           throws javax.servlet.jsp.JspException
Specified by:
doTag in interface javax.servlet.jsp.tagext.SimpleTag
Overrides:
doTag in class javax.servlet.jsp.tagext.SimpleTagSupport
Throws:
javax.servlet.jsp.JspException

rescale

protected boolean rescale(Content parentContentNode,
                          Content imageContentNode)
Checks to see if the previously scaled image needs to be rescaled. This is true when the parent content node has been updated or the height or width parameters have changed.

Parameters:
parentContentNode - The node containing the scaled image node
imageContentNode - The scaled image node
Returns:

cleanUp

public void cleanUp()
Set objects to null.


getFilename

protected String getFilename()
Specified by:
getFilename in class BaseImageTag


Copyright © 2003-2012 Magnolia International Ltd.. All Rights Reserved.