Magnolia 5.7 reached extended end of life on May 31, 2022. Support for this branch is limited, see End-of-life policy. Please note that to cover the extra maintenance effort, this EEoL period is a paid extension in the life of the branch. Customers who opt for the extended maintenance will need a new license key to run future versions of Magnolia 5.7. If you have any questions or to subscribe to the extended maintenance, please get in touch with your local contact at Magnolia.
imgfn
templating functions provide useful functions for handling image resources stored in any workspace. They are commonly used to resolve image variations.
Magnolia recommends you store images in the DAM workspace and use
damfn
templating functions instead to benefit from the DAM API (see How to work with images using damfn).
Get image variation link
Retrieves a link to an image variation from binary content.
Method signature
String getImageVariationLinkFromBinary(ContentMap binaryContent, String variation)
or
String getImageVariationLinkFromBinary(Node binaryContent, String variation)
Arguments
binaryContent
| required Either the ContentMap or the Node of the binary you want to render. |
variation
| optional An image variation defined in the site theme.
|
Returns
String
A link to an image variation.
Usage
imgfn.getImageVariationLinkFromBinary(binaryContent, variation)
[#assign binaryNode = cmsfn.asJCRNode(content).getNode('binaryNodeName')] [#assign imgLink = imgfn.getImageVariationLinkFromBinary(binaryNode,'original')] [#assign imgLink240 = imgfn.getImageVariationLinkFromBinary(binaryNode,'240')]
The example above assumes that you have defined an image variation named 240
in your theme.
binaryNodeName
is the default name of the subnode that contains the file binary and related information. Use cmsfn to transform this node into a JCR node that can be used in templating function arguments.