Video field
Purpose
A video from the media library or an external URL (YouTube, Vimeo, …).
Field type name
video
Settings
| Setting | Description |
|---|---|
| Instructions | Shown to editors below the field label. (max 2000 characters) |
| Allow Media Library Videos | Accept videos uploaded to WordPress. |
| Allow External URLs | Accept links such as YouTube or Vimeo URLs. |
| Allowed File Types | Leave empty to accept every video type, or list MIME types such as video/mp4. |
| Return Format | What cafe_get_field() returns. |
| 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. |
| Width | Width on edit screens, to place fields side by side: 100 (full), 75, 66, 50, 33 or 25 (%). Phones always show full width. |
| 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):
[
'source' => 'url', // or 'attachment'
'id' => null, // attachment ID for library videos
'url' => 'https://www.youtube.com/watch?v=…',
'provider' => 'youtube', // 'youtube', 'vimeo', a custom provider, or null
'mime_type' => null, // e.g. 'video/mp4' for library videos
]
url returns just the URL.
Example
$video = cafe_get_field( 'intro_video' );
if ( $video && 'attachment' === $video['source'] ) {
echo wp_video_shortcode( [ 'src' => $video['url'] ] );
} elseif ( $video ) {
echo wp_oembed_get( $video['url'] ); // Embeds YouTube, Vimeo, …
}