Advanced Custom Fields oembed only outputs YouTube URL

Having the exact same problem as @Hjalmar on Advanced Custom Fields, but still no fix. Only the URL text displays.

Tried the original ACF oembed option:

div class="embed-container"

    ?php echo get_field('video_embedd'); ?

/div

No luck.

Placed the YouTube embed URL in the ACF text field and outputting it into an HTML iframe:

?php

$videoEmbeddPlease = get_field('video_embedd');

if (!empty($videoEmbeddPlease)): ?

    iframe width="560" height="315" src="?php echo $videoEmbeddPlease?" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen/iframe

?php endif ?

No luck.

Even tried the Advanced ACF example:

?php

// get iframe HTML
$iframe = get_field('video_embedd');

// use preg_match to find iframe src
preg_match('/src="(.+?)"/', $iframe, $matches);
$src = $matches[1];

// add extra params to iframe src
$params = array(
'controls'    = 0,
'hd'        = 1,
'autohide'    = 1
);

$new_src = add_query_arg($params, $src);

$iframe = str_replace($src, $new_src, $iframe);

// add extra attributes to iframe html
$attributes = 'frameborder="0"';

$iframe = str_replace('/iframe', ' ' . $attributes . '/iframe', $iframe);

// echo $iframe
echo $iframe;

?

Even tried the WYSIWYG option.

?php the_field('video_embedd'); ?

Still! No embedded video display, just the YouTube URL text on the screen.

Any help would be incredible.

Thank you!

Topic advanced-custom-fields oembed Wordpress

Category Web


It's also possible that google is blocking the api request to fetch the embed data.

ACF uses the wp_oembed_get function which goes off and grabs metadata from Youtube before displaying the iframe.

Sometimes google may block your server or network if it thinks you have been making too many requests. Google will return the confirm you're not a robot page with the message

"Our systems have detected unusual traffic from your computer network"


Such happens when video is not publicly accessible. In my case the video was simply removed from YouTube by their author and ACF's oEmbed module was unable to get metadata to properly display video.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.