theme_file_icon

  1. drupal
    1. 8
    2. 7
Versions
8 – 7 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.

Related topics

Code

modules/file/file.module, line 744

<?php
function theme_file_icon($variables) {
  $file = $variables['file'];
  $icon_directory = $variables['icon_directory'];

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