public static function getTypeFromMimeMapping($mimeType, $filename)
{
if ($mimeType == "directory") {
return "folder";
}
$type = null;
$mappings = ["unknown" => ["/\\.stp\$/"], "image" => ["/image/", "/\\.eps\$/", "/\\.ai\$/", "/\\.svgz\$/", "/\\.pcx\$/", "/\\.iff\$/", "/\\.pct\$/", "/\\.wmf\$/"], "text" => ["/text/", "/xml\$/"], "audio" => ["/audio/"], "video" => ["/video/"], "document" => ["/msword/", "/pdf/", "/powerpoint/", "/office/", "/excel/", "/opendocument/"], "archive" => ["/zip/", "/tar/"]];
foreach ($mappings as $assetType => $patterns) {
foreach ($patterns as $pattern) {
if (preg_match($pattern, $mimeType . " ." . File::getFileExtension($filename))) {
$type = $assetType;
break;
}
}
// break at first match
if ($type) {
break;
}
}
if (!$type) {
$type = "unknown";
}
return $type;
}