This documentation describes unreleased changes on the main branch.

wp_attachment_image()

Twig function of the framework; its result is HTML and is printed without escaping.

{{ wp_attachment_image(id, size = 'full', attributes = {}) }}

An image from the media library as an img element, as returned by wp_get_attachment_image(). The output is HTML and is printed unescaped. Returns '' if the ID is null, the attachment does not exist or has no image.

{{ wp_attachment_image(attrs.imageId, 'large', { class: 'rounded' }) }}
ParameterTypeDefaultDescription
idint|nullrequiredID of the attachment, e.g. from an #[Image] attribute.
sizestring'full'Registered image size, e.g. thumbnail, medium, large or full.
attributesarray<string, string>[]Additional attributes of the img element.

Returns string