How does facebook’s Share a link feature work?


I wanted to implement that feature in a Rails application I’m buidling.
A user posts a url, and voila, he gets a better representation for that

I already dealt with a similar feature before where the requirement was
to replace a given url with the page’s title and favicon.

Facebook go beyond that and if it’s youtube it gives you an embed object
and so on. I asked the same question on stackoverflow

where I was introduced to oEmbed and oohEmbed. I guess they are great.

What I want exactly is

  1. A user attaches a url with his blog post for example
  2. when showing that blog post, one of the following things should
    a) If youtube and other video sites, embed that video in its proper
    b) if an image, show the thumbnail
    c) else, show a page’s title and description

I wanted to know what ideas come to your mind if you were faced with
implementing such a feature. One thing to mention is that this feature
will be used in my application heavily, or should I say all the time so
the solution should really pay much attention to performance.