function manualcrop_croptool_submit in Manual Crop 7
Form submit handler; Saves each crop selection.
1 call to manualcrop_croptool_submit()
- manualcrop_field_attach_submit in ./
manualcrop.module - Implements hook_field_attach_submit().
1 string reference to 'manualcrop_croptool_submit'
- _manualcrop_process_file_entity_form in ./
manualcrop.helpers.inc - Add the crop functionality to the File Entity form.
File
- ./
manualcrop.module, line 497
Code
function manualcrop_croptool_submit($form, &$form_state) {
static $submitted = FALSE;
if (!$submitted && !empty($form_state['manualcrop_data']['selections'])) {
// Loop trough the selections to save them.
foreach ($form_state['manualcrop_data']['selections'] as $fid => $data) {
// In general this file entity should be loaded from a cache, so this
// should not cost any performance.
manualcrop_save_crop_data(file_load($fid), $data['styles']);
// Clear the cached versions of this image.
image_path_flush($data['path']);
}
if (variable_get('manualcrop_cache_control', TRUE)) {
// Clear the cached image paths.
cache_clear_all('manualcrop:', 'cache', TRUE);
}
// Show a success message when not using the FAPI.
if (!empty($form['manualcrop'])) {
drupal_set_message(t('The crop selections have been saved.'));
}
// Prevent additional submits.
unset($form_state['manualcrop_data']['selections']);
$submitted = TRUE;
}
}