-
Notifications
You must be signed in to change notification settings - Fork 0
Image
The Image field builds on top of the File field and only allows the selection of images.
The Image field has the same settings as the File field. The only exception is the output format, described below.
The image field supports the following output types for when it is used in combination with a the_value
function:
-
image
: Generates a complete image tag (default). -
link
: Generates a link to the image. -
url
: Generates the URL of the image. -
id
: Returns the ID of the image.
In PHP you can use the set_output_type
method in combination with one of the slugs above.
If you have set the "Output Type" to image, you can adjust which image size should be used when the image is generated.
In PHP use the set_output_size
method along with the slug of the image size, added by add_image_size
.
Field::create( 'image', 'header_image' )->set_output_size( 'header' );
When you use an image field in combination with a get_value
function, the ID of the selected image will be returned, if any.
the_value
functions will display the type of value, selected for "Output Type".
<!-- Displays a full img tag when output type is set to `image` -->
<?php the_value( 'header_image' ) ?>
Quick start
- Creating fields and using their values
- Installation
- Administration interface
- Using the PHP API
- Container Settings
Locations
- Overview & Usage
- Post Type
- Options Page
- Taxonomy
- Comment
- User
- Widget
- Shortcode
- Menu Item
- Attachment
- Customizer
Fields
- Fields
- Text
- Textarea
- WYSIWYG
- Password
- Checkbox
- Select
- Multiselect
- Image Select
- File
- Image
- Audio
- Video
- Gallery
- WP Object
- WP Objects
- Link
- Date
- DateTime
- Time
- Color
- Font
- Icon
- Map
- Embed
- Number
- Sidebar
- Complex
- Repeater
- Layout
- Section
- Tab
- Message
Features
- Adding fields to the Customizer
- Conditional Logic
- Front-End Forms
- Administration columns
- Import and Export
- REST API
- JSON Synchronization
- Yoast SEO
Ultimate Post Types
Functions and API
Tutorials