1 image.module image_styles()

Get an array of all styles and their settings.

Return value

An array of styles keyed by the image style ID (isid).:

See also

image_style_load()

File

core/modules/image/image.module, line 492
Exposes global functionality for creating image styles.

Code

function image_styles() {
  $styles = &backdrop_static(__FUNCTION__);

  // Grab from cache or build the array.
  if (!isset($styles)) {
    if ($cache = cache()->get('image_styles')) {
      $styles = $cache->data;
    }
    else {
      $styles = array();

      // Select the styles we have configured.
      foreach (config_get_names_with_prefix('image.style') as $config_name) {
        $style = array();
        $config = config($config_name);
        $style['label'] = $config->get('label');
        $style['name'] = $config->get('name');
        $style['effects'] = array();
        if ($module = $config->get('module')) {
          $style['module'] = $module;
          $style['storage'] = $config->get('overridden') ? IMAGE_STORAGE_OVERRIDE : IMAGE_STORAGE_DEFAULT;
        }
        else {
          $style['storage'] = IMAGE_STORAGE_NORMAL;
        }
        foreach ($config->get('effects') as $key => $effect) {
          // Do not include effects for definitions that are missing.
          if ($definition = image_effect_definition_load($effect['name'])) {
            $effect = array_merge($definition, $effect);
            $effect['ieid'] = $key;
            $style['effects'][$key] = $effect;
          }
        }
        // Sort the effects by weight.
        backdrop_sort($style['effects'], array('weight', 'ieid'));
        $styles[$style['name']] = $style;
      }
      backdrop_alter('image_styles', $styles);
      cache()->set('image_styles', $styles);
    }
  }

  return $styles;
}