You are here

function theme_media_flickr_embed in Media: Flickr 7.2

Same name and namespace in other branches
  1. 7 themes/media_flickr.theme.inc \theme_media_flickr_embed()
3 theme calls to theme_media_flickr_embed()
theme_media_flickr_field_formatter_styles in themes/media_flickr.theme.inc
theme_media_flickr_preview_style in themes/media_flickr.theme.inc
@file Theme functions for the Media: Flickr module.
theme_media_flickr_styles in themes/media_flickr.theme.inc

File

themes/media_flickr.theme.inc, line 47
Theme functions for the Media: Flickr module.

Code

function theme_media_flickr_embed($variables) {
  if (isset($variables['preset']) && isset($variables['object'])) {

    //get preset information from the variables object.
    $preset_name = $variables[(string) 'preset'];
    $all_presets = $variables[(string) 'presets'];
    $preset = array(
      'effects' => $all_presets[(string) 'presets'][(string) $preset_name],
    );

    // Build the URL for display.
    $uri = $variables['uri'];
    $wrapper = file_stream_wrapper_get_instance_by_uri($uri);
    $parts = $wrapper
      ->get_parameters();
    $width = $height = 0;
    foreach ($preset['effects'] as $effect) {
      if ($effect['name'] === 'resize') {
        $width = isset($effect['settings']['width']) ? $effect['settings']['width'] : NULL;
        $height = isset($effect['settings']['height']) ? $effect['settings']['height'] : NULL;
      }
    }
    if (isset($variables['object']->override)) {
      $override = $variables['object']->override;
      if (isset($override['width'])) {
        $width = $override['width'];
      }
      if (isset($override['height'])) {
        $height = $override['height'];
      }
      if (isset($override['thumbnail'])) {
        unset($variables['photoset']);
        unset($variables['search']);
      }
    }
    $attributes = array();
    if ($width) {
      $attributes['width'] = $width;
    }
    if ($height) {
      $attributes['height'] = $height;
    }

    // If this is a photoset, then return the flash object for that.
    if (!isset($parts['p'])) {
      if (isset($variables['search']) || isset($variables['photoset']) && $variables['photoset']) {
        $attributes['uri'] = $uri;
        return theme('media_flickr_photoset', $attributes);
      }
      $parts['p'] = media_flickr_photoset_photo_id($uri);
    }
    return theme('image', array(
      'path' => media_flickr_image_url($parts['p'], $width, $height),
      'alt' => $variables['alt'],
      'title' => $variables['title'],
      'attributes' => $attributes,
      'getsize' => FALSE,
    ));
  }
  return '';
}