Last active
August 21, 2017 15:09
-
-
Save erezLieberman/f2ac621fefbac7219abd to your computer and use it in GitHub Desktop.
embed video to wp acf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="videoWrapper"> | |
<!-- from here: http://css-tricks.com/NetMag/FluidWidthVideo/Article-FluidWidthVideo.php --> | |
<?php if( get_field('youtube_url') ){ | |
$embed_code = wp_oembed_get( get_field('youtube_url') ); | |
echo $embed_code; | |
} ?> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
if you want auto play use this in functions.php:
function modify_youtube_embed_url($html) {
return str_replace("?feature=oembed", "?feature=oembed&autoplay=1", $html);
}
add_filter('oembed_result', 'modify_youtube_embed_url');
if its inside modal use this in jquery:
//play and stop the youtube video inside the bootstrap modal
youtube_url = $('.backstrach_img .embed-container iframe').attr('src');
youtube_url = youtube_url.replace("?feature=oembed", "?feature=oembed&autoplay=1");
$('.play_btn').on('click',function(){
$('.backstrach_img .embed-container iframe').attr('src',youtube_url);
})