Advertisement
jcisio

Untitled

Mar 6th, 2012
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. /**
  2. * Supports OpenGraphProtocol
  3. */
  4. function ttcn_opengraph(&$vars) {
  5. if (arg(0) == 'node') {
  6. $node = menu_get_object();
  7. if ($node->field_thumbnail[0]['value']) {
  8. $image = $node->field_thumbnail[0]['value'];
  9. }
  10. elseif (!empty($node->field_thumbnail_image[0]['filepath'])) {
  11. $image = '/' . $node->field_thumbnail_image[0]['filepath'];
  12. }
  13. elseif (!empty($node->field_product_image[0]['filepath'])) {
  14. $image = '/' . $node->field_product_image[0]['filepath'];
  15. }
  16. }
  17. elseif (arg(0) == 'user') {
  18. $user = menu_get_object('user_uid_optional');
  19. if ($user->picture) {
  20. $image = '/' . $user->picture;
  21. }
  22. }
  23. if (empty($image)) {
  24. $image = '/sites/default/files/misc/icon.png';
  25. }
  26.  
  27. if ($title = drupal_get_title()) {
  28. $vars['head'] .= '<meta property="og:title" content="' . str_replace('"', '&quot;', strip_tags($title)) .'" />' . "\n";
  29. }
  30. if (strpos($image, '://') === FALSE) {
  31. $image = 'http://vtcdn.com' . str_replace('/files/', '/files/imagecache/s180/', $image);
  32. }
  33. $vars['head'] .= '<meta property="og:image" content="' . $image . '" />' . "\n";
  34.  
  35. if (request_uri() == '/') {
  36. $type = 'website';
  37. }
  38. elseif (arg(0) == 'blogs') {
  39. $type = 'blog';
  40. }
  41. else {
  42. $type = 'article';
  43. }
  44. $vars['head'] .= '<meta property="og:type" content="' . $type . '" />' . "\n";
  45.  
  46. $vars['head'] .= '<meta property="og:url" content="' . token_replace('[metatags-url-alias]') . '" />' . "\n";
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement