summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwebchick2014-07-13 20:21:15 (GMT)
committerwebchick2014-07-13 20:21:15 (GMT)
commitd14ea92b8680371cefc7ca6ad13c3138b751f1a1 (patch)
tree1d73fce486ddda89f531226da487e8ed84f98ed7
parente008d3a505f1dbf63de812a326a46f7e6885f03b (diff)
Issue #2163209 by andrewmacpherson, mgifford | Charles Belov: Add alternate text to file icon.
-rw-r--r--core/modules/file/file.module21
1 files changed, 20 insertions, 1 deletions
diff --git a/core/modules/file/file.module b/core/modules/file/file.module
index 52a255a..97fa6ff 100644
--- a/core/modules/file/file.module
+++ b/core/modules/file/file.module
@@ -1603,10 +1603,29 @@ function template_preprocess_file_link(&$variables) {
$url = file_create_url($file->getFileUri());
$file_entity = ($file instanceof File) ? $file : file_load($file->fid);
+
+ // Human-readable names, for use as text-alternatives to icons.
+ $mime_name = array(
+ 'application/msword' => t('Microsoft Office document icon'),
+ 'application/vnd.ms-excel' => t('Office spreadsheet icon'),
+ 'application/vnd.ms-powerpoint' => t('Office presentation icon'),
+ 'application/pdf' => t('PDF icon'),
+ 'video/quicktime' => t('Movie icon'),
+ 'audio/mpeg' => t('Audio icon'),
+ 'audio/wav' => t('Audio icon'),
+ 'image/jpeg' => t('Image icon'),
+ 'image/png' => t('Image icon'),
+ 'image/gif' => t('Image icon'),
+ 'application/zip' => t('Package icon'),
+ 'text/html' => t('HTML icon'),
+ 'text/plain' => t('Plain text icon'),
+ 'application/octet-stream' => t('Binary Data'),
+ );
+
$variables['icon'] = array(
'#theme' => 'image__file_icon',
'#uri' => file_icon_url($file_entity, $icon_directory),
- '#alt' => '',
+ '#alt' => (!empty($mime_name[$file->getMimeType()])) ? $mime_name[$file->getMimeType()] : t('File'),
'#title' => String::checkPlain($file_entity->getFilename()),
'#attributes' => array('class' => 'file-icon'),
);