tags:

views:

123

answers:

1

I am looking for a jQuery plugin with PHP script to do the same as in facebook "attach link" action, where facebook gives the user a list of thumbnails from the external link to represent the link. thanks!

A: 

So the Facebook script is tricky because it scans the link, grabs the images, and displays the images in a way where you can cycle through them before picking which one you want. The logic behind that is very tricky. There are some similar JQuery plugins floating around. Here's one that uses static URLs and Youtube to do the trick. May be a good starting point for you.

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";
  }
}
TALLBOY