Skip to main content

Image

Image objects represent image attachments in WordPress. You don't access images directly as a root provider — instead, they appear when you chain into an image field from another provider.

How you get an Image object:

{{ post.thumbnail }}          <!-- Featured image -->
{{ site.icon }} <!-- Site icon -->
{{ item.thumbnail }} <!-- Featured image inside a Loop -->

Once you have an Image object, all the fields below are available.

All Fields

FieldArgumentsReturnsDescription
idintAttachment ID
titlestringImage title
namestringImage name (alias for slug)
slugstringAttachment slug
captionstringImage caption
statusstringAttachment status
srcsizestringImage URL
srcsetsizestringSrcset attribute value
img_sizessizestringSizes attribute value
widthintWidth in pixels
heightintHeight in pixels
aspectfloatAspect ratio
altstringAlt text
sizesarrayAvailable sizes metadata
mime_typestringMIME type (image/jpeg, etc.)
filestringRelative file path
file_locstringAbsolute file path
extensionstringFile extension
sizeintFile size in bytes
contentstringAttachment description
excerptstringAttachment caption
linkstringAttachment page URL
pathstringAttachment page path
edit_linkstringAdmin edit URL
dateformatstringUpload date
timeformatstringUpload time
timestampintUnix timestamp
modified_dateformatstringModified date
modified_timeformatstringModified time
modified_timestampintModified unix timestamp
authorUserUploader
parentPostParent post
can_editboolCurrent user can edit
metafield_namemixedImage meta value
raw_metafield_namemixedUnescaped meta value
has_fieldfield_nameboolCheck if field exists

Image Source

The src field accepts an optional size parameter:

{{ post.thumbnail.src }}                    <!-- Full size URL -->
{{ post.thumbnail.src('thumbnail') }} <!-- 150x150 -->
{{ post.thumbnail.src('medium') }} <!-- 300px max -->
{{ post.thumbnail.src('medium_large') }} <!-- 768px max -->
{{ post.thumbnail.src('large') }} <!-- 1024px max -->
{{ post.thumbnail.src('custom-size') }} <!-- Custom registered size -->

For responsive images:

{{ post.thumbnail.srcset }}
{{ post.thumbnail.img_sizes }}

Dimensions

{{ post.thumbnail.width }}
{{ post.thumbnail.height }}
{{ post.thumbnail.aspect }}

Metadata

{{ post.thumbnail.alt }}
{{ post.thumbnail.mime_type }}
{{ post.thumbnail.sizes }}

File Info

{{ post.thumbnail.file }}
{{ post.thumbnail.extension }}
{{ post.thumbnail.size }}

Content

{{ post.thumbnail.content }}      <!-- Description -->
{{ post.thumbnail.excerpt }} <!-- Caption -->

URLs

{{ post.thumbnail.link }}         <!-- Attachment page URL -->
{{ post.thumbnail.edit_link }}

Dates

{{ post.thumbnail.date('F j, Y') }}
{{ post.thumbnail.timestamp }}
{{ post.thumbnail.modified_date('Y-m-d') }}

Author & Parent

{{ post.thumbnail.author.name }}
{{ post.thumbnail.parent.title }}

Custom Fields (Meta)

{{ post.thumbnail.meta('photographer') }}
{{ post.thumbnail.meta('copyright') }}
{{ post.thumbnail.has_field('credit') }}

Note: Private meta keys (starting with _) are blocked for security.

Common Patterns

Responsive image

<img
src="{{ post.thumbnail.src('large') }}"
srcset="{{ post.thumbnail.srcset }}"
sizes="{{ post.thumbnail.img_sizes }}"
alt="{{ post.thumbnail.alt }}"
width="{{ post.thumbnail.width }}"
height="{{ post.thumbnail.height }}"
>
{{ post.thumbnail.src('large') ?? '/default-image.jpg' }}

Alt text with fallback

{{ post.thumbnail.alt ?? post.thumbnail.title ?? 'Image' }}

Site icon

{{ site.icon.src('thumbnail') }}