You are here

function fb_opengraph_preprocess_page in Drupal for Facebook 7.4

Implements hook_preprocess_page().

Adds our meta tags to the html header.

File

./fb_opengraph.module, line 210
Open Graph Helpers

Code

function fb_opengraph_preprocess_page(&$vars) {
  $tags = fb_opengraph_get_tags(TRUE);
  if (count($tags)) {
    foreach ($tags as $key => $value) {
      if (is_array($value)) {

        // Arrays represent multiple properties for same key.  I.e. og:image
        foreach ($value as $val) {
          drupal_add_html_head(array(
            '#tag' => 'meta',
            '#attributes' => array(
              'property' => $key,
              'content' => $val,
            ),
          ), $key);
        }
      }
      else {
        drupal_add_html_head(array(
          '#tag' => 'meta',
          '#attributes' => array(
            'property' => $key,
            'content' => $value,
          ),
        ), $key);
      }
    }
  }
}