From d14ea92b8680371cefc7ca6ad13c3138b751f1a1 Mon Sep 17 00:00:00 2001
From: webchick <drupal@webchick.net>
Date: Sun, 13 Jul 2014 13:21:15 -0700
Subject: [PATCH] Issue #2163209 by andrewmacpherson, mgifford | Charles Belov:
 Add alternate text to file icon.

---
 core/modules/file/file.module | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/core/modules/file/file.module b/core/modules/file/file.module
index 52a255a4270b..97fa6ff7c0e6 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'),
   );
-- 
GitLab