file_icon_class($mime_type)
Gets a class for the icon for a MIME type.
string $mime_type: A MIME type.
string A class associated with the file.
function file_icon_class($mime_type) { // Search for a group with the files MIME type. $generic_mime = (string) file_icon_map($mime_type); if (!empty($generic_mime)) { return $generic_mime; } // Use generic icons for each category that provides such icons. foreach (array('audio', 'image', 'text', 'video') as $category) { if (strpos($mime_type, $category) === 0) { return $category; } } // If there's no generic icon for the type the general class. return 'general'; }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!file!file.module/function/file_icon_class/8.1.x