diff options
author | Silvio <silvio@devlet.com.br> | 2011-11-18 15:29:11 -0200 |
---|---|---|
committer | Silvio <silvio@devlet.com.br> | 2011-11-18 15:29:11 -0200 |
commit | 7c275a1f2b3043e057dc6de76b3b050ab8602da7 (patch) | |
tree | bcfefc9054f6404261e58663c4863bdbad40e14b /imagecache_auto.inc | |
parent | 385ba95d9f725fa79ceaca506aa2586eb8a42f89 (diff) | |
download | imagecache_auto-7c275a1f2b3043e057dc6de76b3b050ab8602da7.tar.gz imagecache_auto-7c275a1f2b3043e057dc6de76b3b050ab8602da7.tar.bz2 |
Check if maximum number of presets was reached
Diffstat (limited to 'imagecache_auto.inc')
-rw-r--r-- | imagecache_auto.inc | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/imagecache_auto.inc b/imagecache_auto.inc index 3541ba3..1b0fe7d 100644 --- a/imagecache_auto.inc +++ b/imagecache_auto.inc @@ -39,6 +39,14 @@ function imagecache_auto_create_preset($options) { return; } + // Check if maximum number of presets was reached. + $max_presets = (int) variable_get('imagecache_auto_max_presets', '250'); + if (imagecache_auto_count_presets() > $max_presets + 1) { + $message = 'Maximum number of imagecache presets reached. Please consider increasing the max number of presets.'; + watchdog('imagecache_auto', $message, array(), WATCHDOG_ERROR); + return; + } + // Create a preset. $preset = imagecache_preset_save(array('presetname' => $name)); @@ -120,3 +128,16 @@ function imagecache_auto_presets() { return $presets; } + +/** + * Count number of existing imagecache presets. + * + * @return + * Number of existing presets. + */ +function imagecache_auto_count_presets() { + $query = 'SELECT COUNT(presetid) AS count FROM imagecache_preset'; + $result = db_query($query); + $count = db_fetch_object($result); + return $count->count; +} |