Text format filter for embedding links and videos into body copy I would like to get a functionality similar to Facebook: when you include any link in a status update, post or comment it will replace it with a thumbnail, link and short description of the page. 

The emfield module has that functionality but it requires an extra field and can't do the replacement within a body copy.

Video Filter does it for videos but it requires a special syntax [video:url] that a user would have to learn. It does offer Wysiwyg integration.

Is there any way of achieving a seamless (Facebook-like) experience?
A quick hack in Drupal 6 for the links would be:

&lt;?php

function MYMODULE_filter($op, $delta=0, $format=-1, $text='') {
  switch ($op) {
    case 'list':
      return array (0 =&gt; t('MYMODULE Open Graph Link Maker'));

    case 'description':
      return t('Changes links into Open Graph Link Blocks with a thumbnail, title, and description');

    case 'no cache':
      return FALSE;

    case 'process':
      return _MYMODULE_og_block($text);

    case 'prepare':
      return $text;
  }
}

function _MYMODULE_og_block($text) {

  $text = preg_replace_callback("`(&lt;p&gt;|&lt;li&gt;|[ \n\r\t\(])(www\.[a-zA-Z0-9@:%_+*~#?&amp;=.,/;-]*[a-zA-Z0-9@:%_+~#\&amp;=/;-])([.,?!]*?)(?=(&lt;/p&gt;|&lt;/li&gt;|&lt;br\s*/?&gt;|[ \n\r\t\)]))`i", '_MYMODULE_link_to_og', $text);

  return $text;

}

function _MYMODULE_link_to_og($match) {

  $all = file_get_contents('http://' . $match[2]);      // alas get_meta_tags() only finds tags with name=, not property= like og: uses so we need to do this ourselves...
  $title=_MYMODULE_get_og_meta('title', $all);
  $image=_MYMODULE_get_og_meta('image', $all);
  $description=_MYMODULE_get_og_meta('description', $all);

  if ($title &amp;&amp; $image) {
    $content=$match[1];
    $content.='&lt;div style="border:1px solid grey;padding:5px;margin:5px;width:300px;"&gt;';
    $content.='&lt;img style="height:50px;width:50px;margin-right:5px;float:left" src="' . $image . '"&gt;';
    $content.='&lt;b&gt;&lt;a target="_blank" href="http://' . $match[2] . '"&gt;' . $title . '&lt;/a&gt;&lt;/b&gt;&lt;br&gt;';
    $content.=$description;
    $content.='&lt;/div&gt;';
    $content.=$match[3];
    return $content;
  } else {
    _filter_url_trim(NULL,72);                       // these might be different in D7
    return _filter_url_parse_partial_links($match);  // but all it does is the default behavior of changing it into a link
  }

}

function _MYMODULE_get_og_meta($meta, $text) {

  $foo=explode('&lt;meta property="og:' . $meta . '" content="', $text);  // I am sure someone out there can do this better with preg_replace_callback :)
  $bar=explode('"', $foo[1]);
  return $bar[0];

}


which looks for www.__ and creates a simple facebook like div from the facebook og: meta tags.  If you wanted to get fancier, of course you could look for the first image etc in the html in a similar fashion if they weren't present.

Now, I know you said you are using drupal 7, and I think that would be just changing MYMODULE_filter() to MYMODULE_filter_info() and changing up the arrays in the return as the filtering code itself should be the same.  Obviously, css style it how you want, I just threw in some quick stuff.

Also, this obviously doesn't do any of the fancy facebook ahah stuff but for something coded while watching Hawaii Five-O, I hope it helps you out a bit :)

Oh, somewhat obviously, to turn it on, you would go into your input filters and add/enable it for filtered_html, for example, and turn off the original one that changes www.__ into links so you don't refilter it again.