A URL field with live preview of embeddable content (YouTube, Vimeo, Twitter, etc.).
Field::oembed(string $key): OembedField->previewWidth(int $px): static // Default: 480
->previewHeight(int $px): static // Default: 270Stored as the raw URL string.
{ "promo_video": "https://www.youtube.com/watch?v=dQw4w9WgXcQ" }Field::oembed('promo_video')
->label('Promo Video')
->previewWidth(640)
->previewHeight(360),Use WordPress's wp_oembed_get() to render the embed:
@php
$url = ctrlfield_get('promo_video');
$html = $url ? wp_oembed_get($url, ['width' => 800]) : '';
@endphp
@if($html)
<div class="video-embed">{!! $html !!}</div>
@endif$url = ctrlfield_get('promo_video');
$html = $url ? wp_oembed_get($url) : '';
if ($html) {
echo wp_kses_post($html);
}