function _filefield_icon_path in FileField 6.2
Same name and namespace in other branches
- 5.2 filefield.module \_filefield_icon_path()
- 6.3 filefield.theme.inc \_filefield_icon_path()
1 call to _filefield_icon_path()
File
- ./
filefield.theme.inc, line 93 - FileField: Defines a CCK file field type.
Code
function _filefield_icon_path($file, $theme = 'protocons') {
// If there's an icon matching the exact mimetype, go for it.
$dashed_mime = strtr($file['filemime'], array(
'/' => '-',
));
if ($iconpath = _filefield_create_icon_path($dashed_mime, $theme)) {
return $iconpath;
}
// For a couple of mimetypes, we can "manually" tell a generic icon.
if ($generic_name = _filefield_generic_icon_map($file)) {
if ($iconpath = _filefield_create_icon_path($generic_name, $theme)) {
return $iconpath;
}
}
// Use generic icons for each category that provides such icons.
foreach (array(
'audio',
'image',
'text',
'video',
) as $category) {
if (strpos($file['filemime'], $category . '/') === 0) {
if ($iconpath = _filefield_create_icon_path($category . '-x-generic', $theme)) {
return $iconpath;
}
}
}
// Try application-octet-stream as last fallback.
if ($iconpath = _filefield_create_icon_path('application-octet-stream', $theme)) {
return $iconpath;
}
// Sorry, no icon can be found...
return FALSE;
}