function manualcrop_force_effect_order in Manual Crop 7
Effect and style form submit handler; Force the Manual Crop effect to be the first one.
4 string references to 'manualcrop_force_effect_order'
- manualcrop_form_image_effect_form_alter in ./
manualcrop.admin.inc - Implements hook_form_FORM_ID_alter().
- manualcrop_form_image_style_form_alter in ./
manualcrop.admin.inc - Implements hook_form_FORM_ID_alter().
- manualcrop_global_settings_form in ./
manualcrop.admin.inc - Form builder; Global settings configuration form.
- manualcrop_uninstall in ./
manualcrop.install - Implements hook_uninstall().
File
- ./
manualcrop.admin.inc, line 507 - Admin functionality for the Manual Crop module.
Code
function manualcrop_force_effect_order($form, &$form_state) {
// In both forms (style and effect) we find the style in the same key.
$style = $form_state['image_style'];
// If it's the style form, check if the style name was updated.
if ($form['#form_id'] == 'image_style_form' && isset($form_state['values']['name']) && $style['name'] != $form_state['values']['name']) {
$style['name'] = $form_state['values']['name'];
}
// The style array is received trough the loader to make sure the function
// works with the latest version.
$style = image_style_load($style['name']);
if (!empty($style['effects'])) {
foreach ($style['effects'] as $eid => $effect) {
if (_manualcrop_is_own_effect($effect)) {
$first = reset($style['effects']);
if ($eid != key($style['effects'])) {
// Change the weight of this effect to the weight of the first effect minus 1.
$effect['weight'] = $first['weight'] - 1;
image_effect_save($effect);
}
break;
}
}
}
}