Skip to content

Commit 8ccc32c

Browse files
authored
Update AllowedMimeTypes.php
- Add getType static method from mime type
1 parent 71d30b1 commit 8ccc32c

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Diff for: src/Media/AllowedMimeTypes.php

+16
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,20 @@ public static function getValidationRule(string $type, bool $as_array = false, ?
132132

133133
return $as_array ? $rules : implode('|', $rules);
134134
}
135+
136+
/**
137+
* Get the type from the mime type
138+
* @param string $mime_type
139+
* @return string|null
140+
*/
141+
public static function getType(string $mime_type): ?string
142+
{
143+
foreach (self::$allowed_mime_types as $type => $mime_types) {
144+
if (in_array($mime_type, $mime_types)) {
145+
return $type;
146+
}
147+
}
148+
149+
return null;
150+
}
135151
}

0 commit comments

Comments
 (0)