function file_entity_match_mimetypes in File Entity (fieldable files) 8.2
Same name and namespace in other branches
- 7.3 file_entity.module \file_entity_match_mimetypes()
- 7.2 file_entity.module \file_entity_match_mimetypes()
Checks if pattern(s) match mimetype(s).
1 call to file_entity_match_mimetypes()
- file_entity_file_type in ./
file_entity.file.inc - Implements hook_file_type().
File
- ./
file_entity.module, line 356 - Extends Drupal file entities to be fieldable and viewable.
Code
function file_entity_match_mimetypes($needle, $haystack) {
$needle = is_array($needle) ? $needle : array(
$needle,
);
$haystack = is_array($haystack) ? $haystack : array(
$haystack,
);
foreach ($haystack as $mimetype) {
foreach ($needle as $search) {
if (fnmatch($search, $mimetype) || fnmatch($mimetype, $search)) {
return TRUE;
}
}
}
return FALSE;
}