You are here

function theme_file_styles_image in Styles 7.2

Same name in this branch
  1. 7.2 contrib/file_styles/file_styles.theme.inc \theme_file_styles_image()
  2. 7.2 contrib/file_styles/includes/themes/file_styles.theme.inc \theme_file_styles_image()
Same name and namespace in other branches
  1. 7 contrib/file_styles/file_styles.theme.inc \theme_file_styles_image()
1 theme call to theme_file_styles_image()
FileStyles::thumbnail in contrib/file_styles/includes/styles/FileStyles.inc

File

contrib/file_styles/file_styles.theme.inc, line 66
Theme functions for File styles.

Code

function theme_file_styles_image($variables) {
  $file = $variables['object'];
  $style_name = $variables['style_name'];
  $vars = array();
  $vars['path'] = $file->uri;

  // Allow image attributes to be provided by the passed-in file object. 'alt'
  // and 'title' need to be separated out because they are treated specially by
  // theme_image().
  if (isset($file->override)) {
    $vars['attributes'] = $file->override;
    foreach (array(
      'alt',
      'title',
    ) as $attribute) {
      if (isset($vars['attributes'][$attribute])) {
        $vars[$attribute] = $vars['attributes'][$attribute];
        unset($vars['attributes'][$attribute]);
      }
    }
  }

  // Add default values for 'alt' and 'title'.
  if (!isset($vars['alt'])) {
    $vars['alt'] = isset($variables['description']) ? $variables['description'] : (isset($file->description) ? $file->description : '');
  }
  if (!isset($vars['title']) || $vars['title'] === '') {
    $vars['title'] = isset($variables['title']) ? $variables['title'] : $vars['alt'];
  }

  // Special case for 'original'.
  // @TODO Certainly can be more elegant than this.
  if ($style_name == 'original') {
    $vars['getsize'] = FALSE;
    return theme('image', $vars);
  }
  $vars['style_name'] = $style_name;

  //@TODO: How to add fields here?
  return theme('image_style', $vars);
}