You are here

function imagecrop_javascript_submit in Image javascript crop 6

Extra submit on the imagecrop action settings form. Reset already cropped images to new width or height, when asked.

1 string reference to 'imagecrop_javascript_submit'
imagecrop_form_imagecache_ui_action_form_alter in ./imagecrop.module
Implementation of hook_form_{form_id}_alter().

File

./imagecrop_actions.inc, line 77
Imagecache actions implementation.

Code

function imagecrop_javascript_submit($form, $form_state) {
  if ($form_state['values']['reset-crops'] === 1) {
    $preset_name = db_result(db_query('SELECT presetname FROM {imagecache_preset} WHERE presetid = %d', $form_state['values']['presetid']));
    if ($preset_name) {
      db_query("UPDATE {imagecrop} SET width = %d, height = %d WHERE presetname = '%s' AND width = %d AND height = %d", $form_state['values']['data']['width'], $form_state['values']['data']['height'], $preset_name, $form_state['values']['old-width'], $form_state['values']['old-height']);
    }
  }
}