You are here

function _imagecache_get_presets in ImageCache 5

9 calls to _imagecache_get_presets()
imagecache_admin in ./imagecache.module
imagecache_field_formatter in ./imagecache.module
Implementation of hook_field_formatter().
imagecache_field_formatter_info in ./imagecache.module
Implementation of hook_field_formatter_info().
imagecache_image_flush in ./imagecache.module
Clear cached versions of a specific file in all presets.
_imagecache_preset_create in ./imagecache.module
Create a preset.

... See full list

File

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

Code

function _imagecache_get_presets($reset = FALSE) {
  static $presets = array();

  // Check caches if $reset is FALSE;
  if (!$reset) {
    if (!empty($presets)) {
      return $presets;
    }

    // Grab from cache saves building the array.
    // Plus it's a frequently used table.
    $cache = cache_get('imagecache:presets', 'cache');
    $presets = unserialize($cache->data);

    // If the preset is not an array, cache_clear_all has been called
    // there no/invalid data in the cache. Fall through and repopulate cache;
    if (is_array($presets)) {
      return $presets;
    }
  }

  // Load Data from the database on reset or if we get invalid data from the array.
  $presets = array();
  $result = db_query('SELECT presetid, presetname FROM {imagecache_preset} ORDER BY presetname');
  while ($row = db_fetch_array($result)) {
    $presets[$row['presetid']] = $row['presetname'];
  }
  cache_set('imagecache:presets', 'cache', serialize($presets));

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