To render images contained in Image Asset or Image Fields, use the
ez_render_field() Twig function.
You can pass the name of an image variation as an argument, for example:
1 2 3 4 5
Render first image¶
If a Content item contains more than one image, you may want to select the first filled image to render.
This enables you to avoid a situation where, for example, the featured image in an article is missing, because the first image Field was left empty.
ez_content_field_identifier_first_filled_image() Twig function
returns the identifier of the first image Field that is not empty.
1 2 3
Configure image variation¶
The same image can have multiple variations differing in things such as scale, cropping, or applied filters.
You can use the built-in image variations or configure your own.
The following example creates a custom variation that scales the image down to a 200 x 200 thumbnail and renders it in grayscale:
1 2 3 4 5 6 7 8 9
To use it, select the variation when rendering the image:
1 2 3 4 5