metatag_opengraph.module 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. /**
  3. * Implements hook_preprocess_html().
  4. */
  5. function metatag_opengraph_preprocess_html(&$variables) {
  6. // Fall back to hook_rdf_namespaces if the rdf module is enabled.
  7. if (module_exists('rdf')) {
  8. return;
  9. }
  10. // @TODO Would it be worth dynamically identifying whether these should be
  11. // added, or just output them all?
  12. // Need an extra namespace for the 'og' tags.
  13. $variables['rdf_namespaces'] .= "\n xmlns:og=\"http://ogp.me/ns#\"";
  14. // Need an extra namespace for the "article" tags.
  15. $variables['rdf_namespaces'] .= "\n xmlns:article=\"http://ogp.me/ns/article#\"";
  16. // Need an extra namespace for the "book" tags.
  17. $variables['rdf_namespaces'] .= "\n xmlns:book=\"http://ogp.me/ns/book#\"";
  18. // Need an extra namespace for the "profile" tags.
  19. $variables['rdf_namespaces'] .= "\n xmlns:profile=\"http://ogp.me/ns/profile#\"";
  20. // Need an extra namespace for the "video" tags.
  21. $variables['rdf_namespaces'] .= "\n xmlns:video=\"http://ogp.me/ns/video#\"";
  22. // And for product tags.
  23. $variables['rdf_namespaces'] .= "\n xmlns:product=\"http://ogp.me/ns/product#\"";
  24. }
  25. /**
  26. * Implements hook_rdf_namespaces().
  27. */
  28. function metatag_opengraph_rdf_namespaces() {
  29. return array(
  30. 'og' => 'http://ogp.me/ns#',
  31. 'article' => 'http://ogp.me/ns/article#',
  32. 'book' => 'http://ogp.me/ns/book#',
  33. 'profile' => 'http://ogp.me/ns/profile#',
  34. 'video' => 'http://ogp.me/ns/video#',
  35. 'product' => 'http://ogp.me/ns/product#',
  36. );
  37. }
  38. /**
  39. * Implements hook_ctools_plugin_api().
  40. */
  41. function metatag_opengraph_ctools_plugin_api($owner, $api) {
  42. if ($owner == 'metatag' && $api == 'metatag') {
  43. return array('version' => 1);
  44. }
  45. }
  46. /*
  47. og:title = [node:title] / [user:name]
  48. og:type = article / profile
  49. og:image = ? / [user:picture:url]
  50. og:url = [node:url] / [user:url]
  51. og:description
  52. og:site_name = [site:name]
  53. og:latitude
  54. og:longitude
  55. og:street-address
  56. og:locality
  57. og:region
  58. og:postal-code
  59. og:country-name
  60. og:email
  61. og:phone_number
  62. og:fax_number
  63. og:video:url
  64. og:video:secure_url
  65. og:video:height
  66. og:video:width
  67. og:video:type
  68. og:audio
  69. og:audio:title
  70. og:audio:artist
  71. og:audio:album
  72. og:audio:type
  73. og:upc
  74. og:isbn
  75. */