You are here

function media_slideshare_file_formatter_image_view in Media: Slideshare 7

Implements hook_file_formatter_FORMATTER_view().

1 string reference to 'media_slideshare_file_formatter_image_view'
media_slideshare_file_formatter_info in ./media_slideshare.module
Implements hook_file_formatter_info().

File

./media_slideshare.module, line 95

Code

function media_slideshare_file_formatter_image_view($file, $display, $langcode) {
  $scheme = file_uri_scheme($file->uri);
  if ($scheme == 'slideshare') {
    $wrapper = file_stream_wrapper_get_instance_by_uri($file->uri);
    $image_style = $display['settings']['image_style'];
    $valid_image_styles = image_style_options(FALSE);
    if (empty($image_style) || !isset($valid_image_styles[$image_style])) {
      $element = array(
        '#theme' => 'image',
        '#path' => $wrapper
          ->getOriginalThumbnailPath(),
      );
    }
    else {
      $element = array(
        '#theme' => 'image_style',
        '#style_name' => $image_style,
        '#path' => $wrapper
          ->getLocalThumbnailPath(),
      );
    }
    return $element;
  }
}