Deprecated function: The each() function is deprecated. This message will be suppressed on further calls in _menu_load_objects() (line 579 of /home/opgnylyd/public_html/includes/menu.inc).

Replacing icons for attachments

31 Oct 2016
Section: 

Description

Replace standard icons of attached files (for the field type - file) on the another icons, for the Drupal themes. And the way to disable them altogether.

Solution

Override function theme_file_icon ($ variables) in the template.php file. YOUR_THEME - the name of your theme, file-icons - folder of icons in the theme folder, and the names of icons of files in that folder must have the original title:

  • application-octet-stream.png
  • application-pdf.png
  • application-x-executable.png
  • audio-x-generic.png
  • image-x-generic.png
  • package-x-generic.png
  • text-html.png
  • text-plain.png
  • text-x-generic.png
  • text-x-script.png
  • video-x-generic.png
  • x-office-document.png
  • x-office-presentation.png
  • x-office-spreadsheet.png

  1. function YOUR_THEME_file_icon($variables) {
  2.   $file = $variables['file'];
  3.   $icon_directory = drupal_get_path('theme', 'ТЕМА') . '/file-icons';
  4.  
  5.   $mime = check_plain($file->filemime);
  6.   $icon_url = file_icon_url($file, $icon_directory);
  7.   return '<img class="file-icon" alt="" title="' . $mime . '" src="' . $icon_url . '" />';
  8. }

And the way to turn off:

  1. function YOUR_THEME_file_icon($variables) {
  2.   return;
  3. }

Comments

cialis generic best price 22 Aug 2020
Trazodone Canada assuhotherse https://cialisse.com/ - cialis online purchase slalmstirl free cialis coupons SimeStuplilt <a href=https://cialisse.com/#>Cialis</a> TakBladial Side Effects Of Cephalexin For Dogs
cialis 5 mg best price usa 17 Sep 2020
Lasix Water Pill Over The Counter assuhotherse https://asocialiser.com/ - Cialis slalmstirl Stendra Cost SimeStuplilt <a href=https://asocialiser.com/#>generic cialis vs cialis</a> TakBladial Free Shipping Stendra