Rendering images using TypoScript
All the content objects available can be created using TypoScript. We will look at the IMAGE
content object. Despite its simplicity, there are various situations, in which it is useful. For example, you might need to render an image on several pages, but don't want to include it in the template because it is dynamic. Using TypoScript, you can use conditionals to control which image is rendered, wrap the image in a link, and more. Here, we will first create a simple image, and then see what other options can be given.
How to do it...
1. Modify the template on any page.
2. Add the following code to the
setup
field, substitutingpage.12
with the path to the object or marker where you want the image to appear:page.12 = IMAGE page.12 { file = fileadmin/image.jpg }
3. Save, clear cache (if necessary), and preview the page.
How it works...
Content objects take certain parameters as an input, and provide HTML as output. In this case, the input is just a path to a file...