function theme_file_icon

7.x file.module theme_file_icon($variables)

Returns HTML for an image with an appropriate icon for the given file.

Parameters

$variables: An associative array containing:

  • file: A file object for which to make an icon.
  • icon_directory: (optional) A path to a directory of icons to be used for files. Defaults to the value of the "file_icon_directory" variable.
  • alt: (optional) The alternative text to represent the icon in text-based browsers. Defaults to an empty string.

Related topics

1 theme call to theme_file_icon()
theme_file_link in drupal/modules/file/file.module
Returns HTML for a link to a file.
2 string references to the theme hook from theme_file_icon()

Note: this list is generated by looking for the string for this theme hook, so it may include some references that are not actually using this theme hook.

file_theme in drupal/modules/file/file.module
Implements hook_theme().
theme_file_link in drupal/modules/file/file.module
Returns HTML for a link to a file.

File

drupal/modules/file/file.module, line 839
Defines a "managed_file" Form API field and a "file" field for Field module.

Code

function theme_file_icon($variables) {
  $file = $variables['file'];
  $alt = $variables['alt'];
  $icon_directory = $variables['icon_directory'];

  $mime = check_plain($file->filemime);
  $icon_url = file_icon_url($file, $icon_directory);
  return '<img class="file-icon" alt="' . check_plain($alt) . '" title="' . $mime . '" src="' . $icon_url . '" />';
}