Support

Account

Home Forums ACF PRO YouTube Thumbnail Object with oEmbed field? Reply To: YouTube Thumbnail Object with oEmbed field?

  • A more universal way would be to get the thumbnail via oEmbed API.

    
    //second false skip ACF pre-processcing
    $url = get_field('videos', false, false);
    //get wp_oEmed object, not a public method. new WP_oEmbed() would also be possible
    $oembed = _wp_oembed_get_object();
    //get provider
    $provider = $oembed->get_provider($url);
    //fetch oembed data as an object
    $oembed_data = $oembed->fetch( $provider, $url );
    $thumbnail = $oembed_data->thumbnail_url;
    $iframe = $oembed_data->html;