Home Forums General Issues oEmbed returning Video Link instead of the Player.


oEmbed returning Video Link instead of the Player.

  • The code snippet from the ACF documentation returns the URL of the media I’m trying to embed instead of the iframe/video player itself.

    <div class="embed-container">
        <?php the_field('video_embed'); ?>
        .embed-container { 
            position: relative; 
            padding-bottom: 56.25%;
            overflow: hidden;
            max-width: 100%;
            height: auto;
        .embed-container iframe,
        .embed-container object,
        .embed-container embed { 
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;

    Is this normal?

    I know that the correct field is being returned with <?php the_field('video_embed'); ?> would love to get some help on how to return the video player/iframe.

    I’ve also tried going the other route with PHP and it’s the same result.

    // Load value.
    $iframe = get_field('oembed');
    // Use preg_match to find iframe src.
    preg_match('/src="(.+?)"/', $iframe, $matches);
    $src = $matches[1];
    // Add extra parameters to src and replace HTML.
    $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);
    // Display customized HTML.
    echo $iframe;

    Would appreciate anyone’s help! And even better if the solution is more like that first snippet, using HTML.

    Many thanks!

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.