damfn templating functions provides access to digital assets such as
images. Use these functions to get an asset from Magnolia’s built-in DAM
or other asset providers. DAM functions also create asset renditions and
links to assets.
Gets the AssetRendition for a given itemKey and renditionName. If
the Asset exists but the rendition is not defined, it returns
default rendition which is the same as the original asset.
Creates a map for a given Asset or a given itemKey containing all
the bean properties of the asset. Additionally the map may contain
further nested maps with the properties of classes implementing
info.magnolia.dam.api.metadata.AssetMetadata. The
metadata submaps are collected under the key metadata.
*) getAssetMapForAssetId(String itemKey) and getAssetMap(String itemKey) are both identical except for handling of non-existent assets. While the getAssetMapForAssetId is null-safe, the getAssetMap is not.
You should always check for existence of assets or provide a fallback when using the getAssetMap method.
Arguments
Argument
Description
asset
required
Asset
itemKey
required
The composed item key.
Returns
Map<String, Object>
A map with the properties of an asset.
Usage
damfn.getAssetMap(asset) or damfn.getAssetMap(itemKey)
The existance of the metadata submaps (see lines 7, 8) depends on the
implementation of your info.magnolia.dam.api.AssetProvider (see
Map
of an asset and its metadata). When JcrAssetProvider (fetching assets
for the workspace dam) metadata.mgnl and metadata.dc are available.
Get link for asset
Gets a link to an Asset. Returns null if Asset is not found or in
case of an exception.
Gets the link to the AssetRendition for a given itemKey and
renditionName. Returns null in the case of an exception or if Asset or
AssetRendition are not found. If the Asset exists but the rendition is
not defined, it returns the link to the default rendition which is
the same as the original asset.