You are here

protected function ShareMessage::addTwitterCardTags in Share Message 7

Adds meta tags in order to share images on Twitter.

Parameters

array $context: The context for the token replacements.

1 call to ShareMessage::addTwitterCardTags()
ShareMessage::buildContent in includes/sharemessage.entity.inc
Overrides Entity::buildContent().

File

includes/sharemessage.entity.inc, line 208
Definition of ShareMessage entity class.

Class

ShareMessage

Code

protected function addTwitterCardTags($context) {
  $twitter = array(
    '#type' => 'html_tag',
    '#tag' => 'meta',
    '#attributes' => array(
      'name' => 'twitter:card',
      'content' => 'summary_large_image',
    ),
  );
  drupal_add_html_head($twitter, 'twitter_card');
  $twitter = array(
    '#type' => 'html_tag',
    '#tag' => 'meta',
    '#attributes' => array(
      'name' => 'twitter:site',
      'content' => variable_get('sharemessage_twitter_user'),
    ),
  );
  drupal_add_html_head($twitter, 'twitter_site');
  $twitter = array(
    '#type' => 'html_tag',
    '#tag' => 'meta',
    '#attributes' => array(
      'name' => 'twitter:description',
      'content' => $this
        ->getTokenizedField('sharemessage_long', $context),
    ),
  );
  drupal_add_html_head($twitter, 'twitter_description');
  if ($this
    ->getImageUrl($context)) {
    $twitter = array(
      '#type' => 'html_tag',
      '#tag' => 'meta',
      '#attributes' => array(
        'name' => 'twitter:image',
        'content' => $this
          ->getImageUrl($context),
      ),
    );
    drupal_add_html_head($twitter, 'twitter_image');
  }
}