Posted By

Uzbekjon on 03/19/09


Tagged

javascript jquery api YouTube


Versions (?)

Who likes this?

7 people have marked this snippet as a favorite

troynt
DrewDouglass
vali29
Nymos
qubestream
Balamir
catrinho


Get YouTube video thumbnails URL with jQuery


 / Published in: jQuery
 

URL: http://jquery-howto.blogspot.com/2009/02/how-to-get-youtube-video-screenshot.html

Lets you get YouTube video scene images by video id or youtube video url using only javascript OR jQuery.

  1. function getScreen( url, size )
  2. {
  3. if(url === null){ return ""; }
  4.  
  5. size = (size === null) ? "big" : size;
  6. var vid;
  7. var results;
  8.  
  9. results = url.match("[\\?&]v=([^&#]*)");
  10.  
  11. vid = ( results === null ) ? url : results[1];
  12.  
  13. if(size == "small"){
  14. return "http://img.youtube.com/vi/"+vid+"/2.jpg";
  15. }else {
  16. return "http://img.youtube.com/vi/"+vid+"/0.jpg";
  17. }
  18. }

Report this snippet  

You need to login to post a comment.