This documentation describes unreleased changes on the main branch.

wp_post_thumbnail()

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

{{ wp_post_thumbnail(id, size = 'post-thumbnail', attributes = {}) }}

The featured image of a post as an img element, as returned by get_the_post_thumbnail(). The output is HTML and is printed unescaped. Returns '' if the ID is null, the post has no featured image, does not exist or is not publicly viewable (except when the block editor renders the block).

{{ wp_post_thumbnail(attrs.target, 'medium', { class: 'teaser-image' }) }}
ParameterTypeDefaultDescription
idint|nullrequiredID of the post, e.g. from a reference attribute.
sizestring'post-thumbnail'Registered image size, e.g. thumbnail, medium, large or full.
attributesarray<string, string>[]Additional attributes of the img element.

Returns string