This documentation describes unreleased changes on the main branch.

wp_attachment_alt()

Twig function of the framework; its result is escaped like any value.

{{ wp_attachment_alt(id) }}

The alternative text of an image from the media library (the meta field _wp_attachment_image_alt), as text. Returns '' if the ID is null, the attachment does not exist or has no alternative text.

<img src="{{ wp_attachment_image_url(attrs.imageId) }}" alt="{{ wp_attachment_alt(attrs.imageId) }}">
ParameterTypeDefaultDescription
idint|nullrequiredID of the attachment.

Returns string