Hi,

I was wondering how to successfully ensure that an image and description are pulled up when a node is posted to facebook? i found a few posts on the subject but no solution other than what I've posted below http://drupal.org/node/363679#comment-1461762, which i' not sure how to implement.

Basic Tags

In order to make sure that the preview is always correctly populated, you should add the tags shown below to your html. An example news story could have the following:

As shown, title contains the preview title, description contains the preview summary and image_src contains the preview image. Please make sure that none of the content fields contain any html markup because it will be stripped out. For consistency's sake, please use the tag to provide text data for the preview, and the tag for any source urls.

The title and summary tags are the minimum requirements for any preview, so make sure to include these two.

Is anyone successfully sharing items from their website with a description and image?

Hope all is well,

Evelyn

Comments

willsteinmetz’s picture

Status: Active » Closed (fixed)

That is something that would have to be included in the theme code, not the module. Please adjust your theme accordingly to follow the fix that you mentioned in the post link about.

nyleve101’s picture

Thank you!

In case any one else needs the code, the code below allows you to successfully share with facebook, just insert it at the top of your relevant node template files.

Code provided by Divesh Kumar:

 drupal_set_html_head("<link rel='image_src' href='".imagecache_create_url('product_pic',str_replace(' ','%20',$node->field_image_product[0]['filepath']))."'  />");
drupal_set_html_head("<meta name='title' content ='$node->title' />");
drupal_set_html_head("<meta name='description' content ='".addslashes(substr(strip_tags($node->content['body']['#value']),0,200))."...' />");

Hope all is well!

Evelyn

willsteinmetz’s picture

Component: Documentation » Code
rimu’s picture

drupal_set_html_head("<meta name=\"description\" content =\"" . strtr(substr(trim(strip_tags($node->content['body']['#value'])),0,200), array("\n" => " ", "\"" => "'", "‘" => "'", "’" => "'", "“" => "'", "”" => "'")) . "...\" />"); worked better for me