views:

186

answers:

1

In video gallerys YouTube shows images of the videos instead of the flash player. If you click on the image, you are redirected to a page where is the flash video player. I want to show the first static images.

How can I do that programmatically?

+3  A: 

For Javascript: (I'm assuming you tagged it as flash because Youtube is a flash video player)

function getScreen( 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";
  }
}

Found here.

Going off of this function, basically you just have to take the v=ladlfasd parameter and put it in this url:

http://img.youtube.com/vi/(v= parameter)/2.jpg

Where it is 2.jpg for small, 0.jpg for large

Chacha102