Created
February 11, 2015 12:31
-
-
Save amiad/a4da927be327c781b3d0 to your computer and use it in GitHub Desktop.
Wordpress colorbox youtube
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
jQuery(document).ready(function($){ | |
$('a[href^="https://www.youtube.com"]').colorbox({iframe:true, innerWidth:640, innerHeight:390, maxWidth:'95%', maxHeight:'95%', href:function(){ | |
var videoId = new RegExp('[\\?&]v=([^&#]*)').exec(this.href); | |
if (videoId && videoId[1]) { | |
return 'https://youtube.com/embed/'+videoId[1]+'?rel=0&wmode=transparent&autoplay=1'; | |
} | |
}}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment