Image field
Purpose
One image from the WordPress media library.
Field type name
image
Settings
| Setting | Description |
|---|---|
| Instructions | Shown to editors below the field label. (max 2000 characters) |
| Return Format | What cafe_get_field() returns. |
| Image Size | Size of the image URL that cafe_get_field() returns. Choices: every registered image size (e.g. Thumbnail 150 × 150, Medium 300 × 300, Large 1024 × 1024) and Full size. |
| Preview Size | How large the chosen image is shown to editors on edit screens (Presentation tab). Does not change the returned value. |
| Allowed File Types | Image formats editors may use, picked from a grouped dropdown (JPG, PNG, WebP, …) or typed as MIME types. Empty = every image format. |
| Default Image | Attachment ID returned when nothing has been saved yet. (min 1, whole number) |
| Translation | How the field behaves in other languages: translate, copy, copy_once or do_not_translate. Used on top-level fields when WPML is active. See WPML. |
| Label per language | The label and instructions per language code while editing in that language, e.g. {"nl": {"label": "Prijs"}}. Set on the Translation tab when WPML is active. See WPML. |
PHP return value
Return Format array (default):
[
'id' => 123,
'url' => 'https://example.com/wp-content/uploads/2026/09/hero.webp',
'width' => 1920,
'height' => 800,
'alt' => 'Hero image',
'title' => 'hero',
'caption' => '',
'mime_type' => 'image/webp',
'size' => 'full',
]
id returns the attachment ID; url returns the URL string. url, width and height use the Image Size setting. If the attachment was deleted, the field reads as null.
Example
$image = cafe_get_field( 'hero_image' );
if ( $image ) {
echo wp_get_attachment_image( $image['id'], 'large' ); // Responsive srcset from WordPress.
}