function file_styles_styles_filter in Styles 7.2
Styles filter callback.
This will determine the correct style container corresponding to media type.
Parameters
$object: A file object with a uri value specified in the $object->uri. Note: the file object may also be sent in a wrapper (Eg, $object->file->uri).
$element: The element parameter is ignored by this callback.
1 string reference to 'file_styles_styles_filter'
- file_styles_styles_default_containers in contrib/
file_styles/ includes/ styles/ file_styles.styles.inc - Implementation of Styles module hook_styles_default_containers().
File
- contrib/
file_styles/ file_styles.module, line 37 - styles/contrib/file_styles/file_styles.module File widget formatter definitions.
Code
function file_styles_styles_filter($object, $element = NULL) {
// Remove the wrapper object from around the actual file, if provided.
if (isset($object->file) && is_object($object->file)) {
$object = $object->file;
}
// Ensure we're working against the fully loaded file object.
$object = file_styles_uri_to_object($object->uri, TRUE);
// Allow other modules to define their own file styles.
// In general, they'll most likely want to check against the mimetype.
$containers = styles_default_containers('file');
$filters = module_invoke_all('file_styles_filter', $object);
foreach ($filters as $filter) {
if (isset($containers['containers'][$filter])) {
return $filter;
}
}
// Now check the part of the mimetype before the slash.
// Note that we can't use strstr($haystack, $needle, $before_needle)
// < PHP 5.3, so we need a work-around.
$filter = file_styles_strstr($object->filemime, '/', TRUE);
if (isset($containers['containers'][$filter])) {
return $filter;
}
// Fallback to default.
return 'default';
}