function image_admin_settings_validate in Image 6
Same name and namespace in other branches
- 7 image.admin.inc \image_admin_settings_validate()
Form validation handler for image admin settings form.
File
- ./
image.admin.inc, line 110
Code
function image_admin_settings_validate($form, &$form_state) {
// Check that the sizes provided have the required amount of information.
$image_sizes = $form_state['values']['image_sizes'];
foreach (element_children($image_sizes) as $key) {
// If there's a label they must provide at either a height or width.
if ($key != IMAGE_ORIGINAL && !empty($image_sizes[$key]['label'])) {
if (empty($image_sizes[$key]['width']) && empty($image_sizes[$key]['height'])) {
form_set_error("image_sizes][{$key}][width", t('You must specify width, height or both dimensions.'));
}
}
}
// Try to create directories and warn the user of errors.
$image_default_path = $form_state['values']['image_default_path'];
$image_path = file_create_path(file_directory_path() . '/' . $image_default_path);
$temp_path = $image_path . '/temp';
if (!file_check_directory($image_path, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS, 'image_default_path')) {
form_set_error('image_default_path', t('You have specified an invalid directory.'));
}
if (!file_check_directory($temp_path, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS, 'image_default_path')) {
form_set_error('image_default_path', t('You have specified an invalid directory.'));
}
}