You are here

public static function ShareaholicPublic::insert_og_tags in Share Buttons, Related Posts, Content Analytics - Shareaholic 8

Same name and namespace in other branches
  1. 7.3 public.php \ShareaholicPublic::insert_og_tags()

Insert the Open Graph Tags

2 calls to ShareaholicPublic::insert_og_tags()
shareaholic_init in ./shareaholic.module
Implements hook_init() This gets called at the beginning of a non-cached page request Ideal for setting response headers
shareaholic_node_view in includes/node.php
Implements hook_node_view()

File

./public.php, line 510

Class

ShareaholicPublic
This class is all about drawing the stuff in publishers' templates that visitors can see.

Code

public static function insert_og_tags($node = false, $view_mode = '') {
  $markup = '';
  $disable_og_tags_check = ShareaholicUtilities::get_option('disable_og_tags');
  if ($disable_og_tags_check && $disable_og_tags_check == 'on') {
    return;
  }
  if ($view_mode != 'full') {
    return;
  }
  if ($node && (!isset($node->shareaholic_options["shareaholic_exclude_og_tags"]) || !$node->shareaholic_options["shareaholic_exclude_og_tags"])) {
    $image_url = self::get_image_url_for($node);
    if (!empty($image_url)) {
      $markup .= "\n<!-- Shareaholic Open Graph Tags -->\n";
      $markup .= "<meta property='og:image' content='" . $image_url . "' />";
      $markup .= "\n<!-- Shareaholic Open Graph Tags End -->\n";
    }
  }
  $element = array(
    '#type' => 'markup',
    '#markup' => $markup,
  );
  drupal_add_html_head($element, 'shareaholic_og_tags');
}