You are here

function imagecache_presets in ImageCache 5.2

Same name and namespace in other branches
  1. 6.2 imagecache.module \imagecache_presets()

Get an array of all presets and their settings.

Parameters

reset: if set to true it will clear the preset cache

Return value

array of presets array( $preset_id => array('presetid' => integer, 'presetname' => string))

12 calls to imagecache_presets()
imagecache_action_delete in ./imagecache.module
imagecache_action_save in ./imagecache.module
imagecache_element_presetname_validate in ./imagecache_ui.module
imagecache_field_formatter_info in ./imagecache.module
Implementation of hook_field_formatter_info().
imagecache_form_alter in ./imagecache_image.module
Add imagecache pipelining to the the image.module size derivatives form

... See full list

File

./imagecache.module, line 737
Dynamic image resizer and image cacher.

Code

function imagecache_presets($reset = false) {
  static $presets = array();

  // Clear  caches if $reset is true;
  if ($reset) {
    $presets = array();
    cache_clear_all('imagecache:presets', 'cache');

    // Clear the content.module cache (refreshes the list of formatters provided by imagefield.module).
    if (module_exists('content')) {
      content_clear_type_cache();
    }
  }

  // Return presets if the array is populated.
  if (!empty($presets)) {
    return $presets;
  }

  // Grab from cache or build the array.
  if ($cache = cache_get('imagecache:presets', 'cache')) {
    $presets = unserialize($cache->data);
  }
  else {
    $result = db_query('SELECT * FROM {imagecache_preset} ORDER BY presetname');
    while ($preset = db_fetch_array($result)) {
      $presets[$preset['presetid']] = $preset;
      $presets[$preset['presetid']]['actions'] = imagecache_preset_actions($preset);
    }
    cache_set('imagecache:presets', 'cache', serialize($presets));
  }
  return $presets;
}