Skip to content

Instantly share code, notes, and snippets.

@amiad
Created February 11, 2015 12:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amiad/a4da927be327c781b3d0 to your computer and use it in GitHub Desktop.
Save amiad/a4da927be327c781b3d0 to your computer and use it in GitHub Desktop.
Wordpress colorbox youtube
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