function media_is_type in D7 Media 7
Default callback used to determine if a file is of a given type.
@TODO: document 'any' and 'all' matching.
Parameters
$file: The file object.
$args:
Return value
unknown_type
2 string references to 'media_is_type'
- media_admin_type_manage_form in includes/
media.admin.inc - The administration form for managing media types.
- media_type_set_defaults in includes/
media.types.inc - Create the basic class and defaults for a media entity bundle type.
File
- includes/
media.types.inc, line 191 - Helper functions related to media types. CRUD for saving their settings mainly.
Code
function media_is_type($file, $args) {
$match_type = !empty($args['match_type']) ? 'any' : $args['match_type'];
$match_all = $match_type == 'all';
if (!empty($args['mimetypes'])) {
foreach ($args['mimetypes'] as $expression) {
if (preg_match($expression, $file->filemime)) {
if (!$match_all) {
return TRUE;
}
}
}
// Was not matched, so return
if ($match_all) {
return FALSE;
}
}
if (!empty($args['extensions'])) {
if (in_array(pathinfo($file->uri, PATHINFO_EXTENSION), $args['extensions'])) {
if (!$match_all) {
return TRUE;
}
}
// Was not matched, so return
if ($match_all) {
return FALSE;
}
}
if (!empty($args['streams'])) {
}
}