You are here

function imagecache_preset_save in ImageCache 5.2

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

Save an ImageCache preset.

Parameters

preset: an imagecache preset array.

Return value

a preset array. In the case of a new preset, 'presetid' will be populated.

2 calls to imagecache_preset_save()
imagecache_ui_preset_add_form_submit in ./imagecache_ui.module
imagecache_ui_preset_form_submit in ./imagecache_ui.module

File

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

Code

function imagecache_preset_save($preset) {

  // @todo: CRUD level validation?
  if (isset($preset['presetid']) && is_numeric($preset['presetid'])) {
    db_query('UPDATE {imagecache_preset} SET presetname =\'%s\' WHERE presetid = %d', $preset['presetname'], $preset['presetid']);
  }
  else {
    $preset['presetid'] = db_next_id('{imagecache_preset}_presetid');
    db_query('INSERT INTO {imagecache_preset} (presetid, presetname) VALUES (%d, \'%s\')', $preset['presetid'], $preset['presetname']);
  }

  // Reset presets cache.
  imagecache_preset_flush($preset);
  imagecache_presets(true);
  return $preset;
}