Skip to content

Instantly share code, notes, and snippets.

@neopunisher
Created July 1, 2013 12:11
Show Gist options
  • Save neopunisher/5900297 to your computer and use it in GitHub Desktop.
Save neopunisher/5900297 to your computer and use it in GitHub Desktop.
/*
* jYoutube 1.0 - YouTube video image getter plugin for jQuery
*
* Copyright (c) 2009 jQuery Howto
*
* Licensed under the GPL license:
* http://www.gnu.org/licenses/gpl.html
*
* Plugin home & Author URL:
* http://jquery-howto.blogspot.com
*
*/
(function($){
$.extend({
jYoutube: function( url, size ){
if(url === null){ return ""; }
size = (size === null) ? "big" : size;
var vid;
var results;
results = url.match("[\\?&]v=([^&#]*)");
vid = ( results === null ) ? url : results[1];
if(size == "small"){
return "http://img.youtube.com/vi/"+vid+"/2.jpg";
}else {
return "http://img.youtube.com/vi/"+vid+"/0.jpg";
}
}
})
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment