Custom Fields
Re-Envisioned
Support General OEmbed Empty Control Reply To: OEmbed Empty Control

#8906

Anh Tran
Keymaster

In the link I pasted above, there’s full code to detect if the URL is a valid oembed, you can try it, like this:

$url = get_post_meta( get_the_ID(), 'oembed', true );
$args = ['width' => 640];
$embed = wp_oembed_get( $url, $args );
if ( ! $embed ) {
    $embed = $GLOBALS['wp_embed']->shortcode( $args, $url );
}
if ( $embed ) {
    echo $embed;
} else {
    // Do something when there's no controls if you want
}