You are here

function twitter_views_handler_field_image::render in Twitter 7.5

Renders the image.

Overrides views_handler_field::render

File

./twitter_views_field_handlers.inc, line 237
Views handlers for Twitter module.

Class

twitter_views_handler_field_image
Renders the image attached to a tweet.

Code

function render($values) {
  if (!empty($values->twitter_entities) && is_string($values->twitter_entities)) {
    $entities = unserialize($values->twitter_entities);

    // Loop over the tweet entities and render the image if it is present.
    if (!empty($entities['media']) && is_array($entities['media'])) {
      foreach ($entities['media'] as $media) {
        if ($media['type'] == 'photo' && !empty($media['media_url'])) {
          $image_path = $GLOBALS['is_https'] ? $media['media_url_https'] : $media['media_url'];
          $image_path .= ':' . $this->options['size'];
          return theme('image', array(
            'path' => $image_path,
            'attributes' => array(
              'class' => 'tweet-image',
            ),
          ));
        }
      }
    }
  }
}