Support

Account

Home Forums Front-end Issues You tube in ACF field

Solved

You tube in ACF field

  • Hello,
    I’m using DIVI theme, I’m Frenh, sorry for my english!
    I just want to display you tube video in front end, with the ACF.
    the plugin youtube picker doesn’t work, I have a PHP error.
    Do you have an idea?

    Or, can I take the url in the ACF and put in a video module on DIVI???
    Thank you for reading! ๐Ÿ™‚

  • I use this code with an oEmbed field, only display the video is there’s a url ๐Ÿ˜‰

    <?php 
    if (get_field('my_video')) {
    ?>
    <div class="media_embed_youtube"><?php the_field('my_video''); ?></div>
        <?php 
      } // end if value
    ?>
  • Hi,
    thanks for reply!
    unfortunately, I use a free version of ACF (V4.4) and I don’t have Oembed Field.
    A plugin exist to add Oembed field, but it doesn’t work.
    I know that I can do that I want with the version 5 of ACF, but it’s not free…

  • Hello, i found a solution, here is the code in the page:

    $video = get_field('video_youtube');
    if (!empty($video)){
    echo video_iframe_YT($video);
    echo '<iframe width="560" height="315" src="' . $video . '" frameborder="0" allowfullscreen></iframe>';
    }

    and the functiun :

    // VIDEO YT : iframe
    function video_iframe_YT($video_url)
    {
    $video_iframe			= '';
    // -----------------
    if( !empty($video_url))
    {
    $video_url = video_cleanURL_YT($video_url);
    $video_iframe = '<iframe width="560" height="315" src="' . $video_url . '"  frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>';
    }
    // -----------------
    return $video_iframe;
    };
    ?>

    I hope it will help someone!

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.