function image_admin_settings_submit in Image 7
Same name and namespace in other branches
- 6 image.admin.inc \image_admin_settings_submit()
Form submit handler for image admin settings form.
1 string reference to 'image_admin_settings_submit'
- image_admin_settings in ./
image.admin.inc - Menu callback; Form builder function for image settings.
File
- ./
image.admin.inc, line 137
Code
function image_admin_settings_submit($form, &$form_state) {
// Ensure that 'image_default_path' variable contains no trailing slash.
$form_state['values']['image_default_path'] = rtrim($form_state['values']['image_default_path'], '/');
// Remove deleted sizes, and use the label as indexes for new sizes.
$old_sizes = image_get_sizes();
// If the size's operation, or dimensions change we need to rebuild.
$rebuild = FALSE;
foreach ($form_state['values']['image_sizes'] as $key => $size) {
// Changed to the original setting only affect new images and they
// shouldn't be able to add or remove it.
if ($key == IMAGE_ORIGINAL) {
continue;
}
// Remove sizes without labels.
if (empty($size['label'])) {
unset($form_state['values']['image_sizes'][$key]);
}
// Check if only one is set, indicating an addition or removal.
if (isset($form_state['values']['image_sizes'][$key]) ^ isset($old_sizes[$key])) {
$rebuild |= TRUE;
// When adding a new size, we need to assign a key.
if (isset($form_state['values']['image_sizes'][$key])) {
unset($form_state['values']['image_sizes'][$key]);
$new_key = drupal_strtolower(drupal_substr($size['label'], 0, 32));
$form_state['values']['image_sizes'][$new_key] = $size;
}
}
else {
if (isset($form_state['values']['image_sizes'][$key]) && isset($old_sizes[$key])) {
// Did the operation, height or width change?
foreach (array(
'operation',
'height',
'width',
) as $field) {
$rebuild |= $form_state['values']['image_sizes'][$key][$field] != $old_sizes[$key][$field];
}
}
}
}
// If we've changed anything update the image_update variable so the
// derivative images are rebuilt.
if ($rebuild) {
drupal_set_message(t('Changes to the images sizes mean that the derivative images will need to be regenerated.'));
$form_state['values']['image_updated'] = time();
}
}