Revision 582db59d
Added by Assos Assos almost 9 years ago
drupal7/modules/file/file.module | ||
---|---|---|
92 | 92 |
'variables' => array('file' => NULL, 'icon_directory' => NULL), |
93 | 93 |
), |
94 | 94 |
'file_icon' => array( |
95 |
'variables' => array('file' => NULL, 'icon_directory' => NULL), |
|
95 |
'variables' => array('file' => NULL, 'icon_directory' => NULL, 'alt' => ''),
|
|
96 | 96 |
), |
97 | 97 |
'file_managed_file' => array( |
98 | 98 |
'render element' => 'element', |
... | ... | |
749 | 749 |
$icon_directory = $variables['icon_directory']; |
750 | 750 |
|
751 | 751 |
$url = file_create_url($file->uri); |
752 |
$icon = theme('file_icon', array('file' => $file, 'icon_directory' => $icon_directory)); |
|
752 |
|
|
753 |
// Human-readable names, for use as text-alternatives to icons. |
|
754 |
$mime_name = array( |
|
755 |
'application/msword' => t('Microsoft Office document icon'), |
|
756 |
'application/vnd.ms-excel' => t('Office spreadsheet icon'), |
|
757 |
'application/vnd.ms-powerpoint' => t('Office presentation icon'), |
|
758 |
'application/pdf' => t('PDF icon'), |
|
759 |
'video/quicktime' => t('Movie icon'), |
|
760 |
'audio/mpeg' => t('Audio icon'), |
|
761 |
'audio/wav' => t('Audio icon'), |
|
762 |
'image/jpeg' => t('Image icon'), |
|
763 |
'image/png' => t('Image icon'), |
|
764 |
'image/gif' => t('Image icon'), |
|
765 |
'application/zip' => t('Package icon'), |
|
766 |
'text/html' => t('HTML icon'), |
|
767 |
'text/plain' => t('Plain text icon'), |
|
768 |
'application/octet-stream' => t('Binary Data'), |
|
769 |
); |
|
770 |
|
|
771 |
$mimetype = file_get_mimetype($file->uri); |
|
772 |
|
|
773 |
$icon = theme('file_icon', array( |
|
774 |
'file' => $file, |
|
775 |
'icon_directory' => $icon_directory, |
|
776 |
'alt' => !empty($mime_name[$mimetype]) ? $mime_name[$mimetype] : t('File'), |
|
777 |
)); |
|
753 | 778 |
|
754 | 779 |
// Set options as per anchor format described at |
755 | 780 |
// http://microformats.org/wiki/file-format-examples |
... | ... | |
779 | 804 |
* - file: A file object for which to make an icon. |
780 | 805 |
* - icon_directory: (optional) A path to a directory of icons to be used for |
781 | 806 |
* files. Defaults to the value of the "file_icon_directory" variable. |
807 |
* - alt: (optional) The alternative text to represent the icon in text-based |
|
808 |
* browsers. Defaults to an empty string. |
|
782 | 809 |
* |
783 | 810 |
* @ingroup themeable |
784 | 811 |
*/ |
785 | 812 |
function theme_file_icon($variables) { |
786 | 813 |
$file = $variables['file']; |
814 |
$alt = $variables['alt']; |
|
787 | 815 |
$icon_directory = $variables['icon_directory']; |
788 | 816 |
|
789 | 817 |
$mime = check_plain($file->filemime); |
790 | 818 |
$icon_url = file_icon_url($file, $icon_directory); |
791 |
return '<img class="file-icon" alt="" title="' . $mime . '" src="' . $icon_url . '" />'; |
|
819 |
return '<img class="file-icon" alt="' . check_plain($alt) . '" title="' . $mime . '" src="' . $icon_url . '" />';
|
|
792 | 820 |
} |
793 | 821 |
|
794 | 822 |
/** |
Also available in: Unified diff
Update Drupal core to version 7.40