function image_styles
7.x image.module | image_styles() |
Gets an array of all styles and their settings.
Return value
An array of styles keyed by the image style ID (isid).
See also
6 calls to image_styles()
- ImageFileMoveTest::testNormal in drupal-7.x/
modules/ simpletest/ tests/ image.test - Tests moving a randomly generated image.
- image_path_flush in drupal-7.x/
modules/ image/ image.module - Clears cached versions of a specific file in all styles.
- image_style_list in drupal-7.x/
modules/ image/ image.admin.inc - Menu callback; Listing of all current image styles.
- image_style_load in drupal-7.x/
modules/ image/ image.module - Loads a style by style name or ID.
- image_style_name_validate in drupal-7.x/
modules/ image/ image.admin.inc - Element validate function to ensure unique, URL safe style names.
9 string references to 'image_styles'
- ImageAdminStylesUnitTest::testDefaultStyle in drupal-7.x/
modules/ image/ image.test - Test to override, edit, then revert a style.
- ImageAdminStylesUnitTest::testStyle in drupal-7.x/
modules/ image/ image.test - General test to add a style, add/remove/edit effects to it, then delete it.
- image_default_style_revert in drupal-7.x/
modules/ image/ image.module - Reverts the changes made by users to a default image style.
- image_schema in drupal-7.x/
modules/ image/ image.install - Implements hook_schema().
- image_style_delete in drupal-7.x/
modules/ image/ image.module - Deletes an image style.
File
- drupal-7.x/
modules/ image/ image.module, line 565 - Exposes global functionality for creating image styles.
Code
function image_styles() {
$styles = &drupal_static(__FUNCTION__);
// Grab from cache or build the array.
if (!isset($styles)) {
if ($cache = cache_get('image_styles', 'cache')) {
$styles = $cache->data;
}
else {
$styles = array();
// Select the module-defined styles.
foreach (module_implements('image_default_styles') as $module) {
$module_styles = module_invoke($module, 'image_default_styles');
foreach ($module_styles as $style_name => $style) {
$style['name'] = $style_name;
$style['label'] = empty($style['label']) ? $style_name : $style['label'];
$style['module'] = $module;
$style['storage'] = IMAGE_STORAGE_DEFAULT;
foreach ($style['effects'] as $key => $effect) {
$definition = image_effect_definition_load($effect['name']);
$effect = array_merge($definition, $effect);
$style['effects'][$key] = $effect;
}
$styles[$style_name] = $style;
}
}
// Select all the user-defined styles.
$user_styles = db_select('image_styles', NULL, array('fetch' => PDO::FETCH_ASSOC))
->fields('image_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('image_styles', $styles);
cache_set('image_styles', $styles);
}
}
return $styles;
}