-
Notifications
You must be signed in to change notification settings - Fork 123
Image Upload Field
Ajit Bohra edited this page Jun 28, 2017
·
11 revisions
Use this field to create allow image uploads.
This field invokes the native WordPress Media Upload. It thereby supports selecting directly from the Media Library, or adding to it via drag/drop. It defaults to the Media Library tab of the uploader.
The value saved is the attachment id.
- id (string) (required)
- name (string) (required) Field display name. Used as field label.
- type 'image' (required)
-
size (string) (optional) - Set display size and crop within the metabox
- Example: 'height=100&width=100&crop=1'
- show_size (bool) (optional) - Display size dimensions in an empty image field.
-
library-type (array) (optional) - By default the image field only includes 'image' other file types can be passed
- Example: 'library-type' => array('image', 'video', 'audio', 'text', 'application' )
array(
'id' => 'example-field-image',
'name' => 'An image input',
'type' => 'image',
),
$image_id = get_post_meta( $my_post_id, 'my-image-meta-id', true ); // Get image ID.
$url = wp_get_attachment_url( $image_id ); // Get the URL only.
wp_get_attachment_image( $image_id ); // Get a full image tag.
- Setup/Install Custom Meta Boxes
- Creating a custom meta box
- Displaying Field Data
- Optional Generic Field Args
- Repeatable Fields
General
- Text Field
- Small Text Field
- Number Field
- URL Field
- Textarea Field
- Code Field
- Select Field
- Checkbox Input Field
- Radio Input Field
Date & Time
WordPress
Media
Utilities