You are here

function theme_file_aliases_imagefield_image in File Aliases 6

Modified version of theme_imagefield_image().

1 string reference to 'theme_file_aliases_imagefield_image'
file_aliases_theme_registry_alter in modules/filefield.inc
Implements hook_theme_registry_alter().

File

modules/filefield.inc, line 54
Contains FileField module integration for the File Aliases module.

Code

function theme_file_aliases_imagefield_image($file, $alt = '', $title = '', $attributes = NULL, $getsize = TRUE) {
  $file = (array) $file;
  if (isset($file['origpath'])) {
    $file['alias'] = $file['filepath'];
    $file['filepath'] = $file['origpath'];
  }
  if (!file_exists($file['filepath'])) {
    return '<!-- File not found: ' . $file['filepath'] . ' -->';
  }
  if ($getsize && (list($width, $height, $type, $image_attributes) = @getimagesize($file['filepath']))) {
    $attributes['width'] = $width;
    $attributes['height'] = $height;
  }
  if (!empty($title)) {
    $attributes['title'] = $title;
  }

  // Alt text should be added even if it is an empty string.
  $attributes['alt'] = $alt;

  // Add a timestamp to the URL to ensure it is immediately updated after editing.
  $query_string = '';
  if (isset($file['timestamp'])) {
    $query_character = variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PRIVATE && variable_get('clean_url', '0') == '0' ? '&' : '?';
    $query_string = $query_character . $file['timestamp'];
  }
  $url = file_create_url(isset($file['alias']) ? $file['alias'] : $file['filepath']) . $query_string;
  $attributes['src'] = $url;
  $attributes = drupal_attributes($attributes);
  return '<img ' . $attributes . ' />';
}