oEmbed field
Purpose
A YouTube, Vimeo, Spotify, SoundCloud… address shown as its embedded player.
Field type name
oembed
Settings
| Setting | Description |
|---|---|
| Instructions | Shown to editors below the field label. |
| Embed Width | Largest width of the embed in pixels (100-3840). |
| Embed Height | Largest height of the embed in pixels (100-2160). |
| Return Format | html (the embed), url or array (url, html). |
| Translation | How the field behaves in other languages: translate, copy, copy_once or do_not_translate. See WPML. |
| Width | Width on edit screens: 100, 75, 66, 50, 33 or 25 (%). |
| Label per language | The label and instructions per language code while editing in that language. See WPML. |
PHP return value
By Return Format: the embed HTML ('' when no embed was available), the URL, or
['url' => …, 'html' => …]; null when empty.
Example
$video = cafe_get_field( 'intro_video' ); // Embed HTML.
if ( $video ) {
echo '<div class="video">' . $video . '</div>'; // Stored HTML is already sanitized.
}