diff --git a/modules/file/file.module b/modules/file/file.module old mode 100644 new mode 100755 index fbf8b81..c5e5e7c --- a/modules/file/file.module +++ b/modules/file/file.module @@ -803,20 +803,40 @@ function theme_file_link($variables) { * An associative array containing: * - file: A file object for which to make an icon. * - icon_directory: (optional) A path to a directory of icons to be used for - * files. Defaults to the value of the "file_icon_directory" variable. - * - alt: (optional) The alternative text to represent the icon in text-based - * browsers. Defaults to an empty string. + * - width: The width of the image (if known). + * - height: The height of the image (if known). + * - alt: The alternative text for text-based browsers. HTML 4 and XHTML 1.0 + * always require an alt attribute. The HTML 5 draft allows the alt + * attribute to be omitted in some cases. Therefore, this variable defaults + * to an empty string, but can be set to NULL for the attribute to be + * omitted. Usually, neither omission nor an empty string satisfies + * accessibility requirements, so it is strongly encouraged for code + * calling theme('image') to pass a meaningful value for this variable. + * - http://www.w3.org/TR/REC-html40/struct/objects.html#h-13.8 + * - http://www.w3.org/TR/xhtml1/dtds.html + * - http://dev.w3.org/html5/spec/Overview.html#alt + * - title: The title text is displayed when the image is hovered in some + * popular browsers. Defaults to the file mime value. + * - attributes: Associative array of attributes to be placed in the img tag. * * @ingroup themeable */ function theme_file_icon($variables) { $file = $variables['file']; - $alt = $variables['alt']; - $icon_directory = $variables['icon_directory']; + $icon_directory = isset($variables['icon_directory']) ? $variables['icon_directory'] : NULL; + $attributes = $variables['attributes']; $mime = check_plain($file->filemime); $icon_url = file_icon_url($file, $icon_directory); - return '' . check_plain($alt) . ''; + $attributes['class'][] = 'file-icon'; + $attributes['title'] = $mime; + foreach (array('width', 'height', 'alt', 'title') as $key) { + + if (isset($variables[$key])) { + $attributes[$key] = $variables[$key]; + } + } + return ''; } /**