function file_styles in Styles 7
Get an array of all styles and their settings.
Return value
An array of styles keyed by the image style ID (isid).
See also
3 calls to file_styles()
- file_style_list in contrib/
file_styles/ file_styles.admin.inc - Menu callback; Listing of all current File styles.
- file_style_load in contrib/
file_styles/ file_styles.module - Load a style by style name or ID. May be used as a loader for menu items.
- file_style_name_validate in contrib/
file_styles/ file_styles.admin.inc - Element validate function to ensure unique, URL safe style names.
6 string references to 'file_styles'
- file_effect_definitions in contrib/
file_styles/ file_styles.module - Pull in file effects exposed by modules implementing hook_file_effect_info().
- file_styles_styles_styles in contrib/
file_styles/ file_styles.module - Implements hook_styles_styles().
- file_style_flush in contrib/
file_styles/ file_styles.module - Flush cached file for a style.
- file_style_save in contrib/
file_styles/ file_styles.module - Save a file style.
- hhhfile_styles in contrib/
file_styles/ file_styles.module - Build a list of all registered File styles.
File
- contrib/
file_styles/ file_styles.module, line 380 - File widget formatter definitions.
Code
function file_styles() {
$styles =& drupal_static(__FUNCTION__);
// Grab from cache or build the array.
if (!isset($styles)) {
if ($cache = cache_get('file_styles', 'cache')) {
$styles = $cache->data;
}
else {
$styles = array();
// Select the module-defined styles.
foreach (module_implements('file_default_styles') as $module) {
$module_styles = module_invoke($module, 'file_default_styles');
foreach ($module_styles as $style_name => $style) {
$style['name'] = $style_name;
$style['module'] = $module;
$style['storage'] = FILE_STORAGE_DEFAULT;
foreach ($style['effects'] as $ieid => $effect) {
$definition = file_effect_definition_load($effect['name']);
$effect = array_merge($definition, $effect);
$effect['meid'] = $ieid;
$style['effects'][$ieid] = $effect;
}
$styles[$style_name] = $style;
}
}
// Select all the user-defined styles.
$user_styles = db_select('file_styles', NULL, array(
'fetch' => PDO::FETCH_ASSOC,
))
->fields('file_styles')
->orderBy('name')
->execute()
->fetchAllAssoc('name', PDO::FETCH_ASSOC);
// Allow the user styles to override the module styles.
foreach ($user_styles as $style_name => $style) {
$style['module'] = NULL;
$style['storage'] = IMAGE_STORAGE_NORMAL;
$style['effects'] = image_style_effects($style);
if (isset($styles[$style_name]['module'])) {
$style['module'] = $styles[$style_name]['module'];
$style['storage'] = IMAGE_STORAGE_OVERRIDE;
}
$styles[$style_name] = $style;
}
drupal_alter('file_styles', $styles);
cache_set('file_styles', $styles);
}
}
return $styles;
}