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.
This page describes how to handle images with Magnolia. This includes both storing the image or a reference to an asset with a dialog and rendering the image in a template script.
Storing a reference of an asset from DAM with
Manage your assets in one central location and reuse them in many different contexts. For example, you can add the same image to a page on your website or to a content item from a content app. To do so:
- Choose the asset in the dialog with a Link field - the dialog saves the reference of the asset.
- In the template, use
damfnto create a link for an image based on the reference.
This approach is explained in more detail in working with images using damfn.
Storing in the same workspace with
imgfn templating functions provide access to images stored in every workspace in the JCR.
You can store images in every workspace. Depending on your use case, you may prefer to store the image in the same workspace as other data in your context. For example, you want store images used on pages in the website workspace, or to store images for a specific content app in the specific content app workspace. With this approach you can publish all the content in one publish action. To do so:
- Use a Basic upload field to store the image (the real binary data) on the workspace of your context. The system creates a subnode of the node of your context. For example, for a subnode of the component node or of a content item, the binary data is stored on a property of the subnode created.
- In the template script, use
imgfnto create an image link with the subnode.
This approach is explained in more detail in working with images using imgfn.