Change or add file icons to Drupal 7. First you have to define your mime type of a file, if it isn't done already. Then add icon URL to that mime type (16x16).
Define mime type
Define your mime type if it haven't been defined already.Source code viewer
function HOOK_file_mimetype_mapping_alter(&$mapping) { $new_mappings['epub'] = 'application/epub+zip'; foreach ($new_mappings as $extension => $mime_type) { // If the mime type does not already exist, add it. $mapping['mimetypes'][] = $mime_type; } $mapping['extensions'][$extension] = $index; } }Programming Language: PHP
Attach image url to mime type
Source code viewer
function THEME_file_icon($variables) { global $base_url; $file = $variables['file']; $icon_directory = $variables['icon_directory']; $mime = check_plain($file->filemime); if ($mime == 'application/epub+zip') { $icon_url = $base_url . base_path() . drupal_get_path('theme', 'ep') . '/img/ico-epub.png'; } else { $icon_url = file_icon_url($file, $icon_directory); } return '<img class="file-icon" alt="" title="' . $mime . '" src="' . $icon_url . '" />'; }Programming Language: PHP