Featured Image

Estimated reading: 1 minute

The WordPress featured image is an image that can be stored with posts. The default ‘post’ post-type has one, and when adding a custom post type you can activate this feature as well.

Display featured image on a single post layout

To access the featured image on a single post layout, all you need to do is access the post.thumbnail property:

<img src="{{ post.thumbnail.src }}" width="{{ post.thumbnail.width }}" height="{{ post.thumbnail.height }}" alt="{{ post.thumbnail.alt }}">

But you might not need the full size image. Timber makes it really easy to access other thumb sizes as well:

<img src="{{ post.thumbnail.src( 'thumbnail' ) }}" width="{{ post.thumbnail.width }}" height="{{ post.thumbnail.height }}" alt="{{ post.thumbnail.alt }}">
Share this Doc

Featured Image

Or copy link

CONTENTS