function image_admin_settings_validate in Image 7
Same name and namespace in other branches
- 6 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.
foreach (element_children($form['image_sizes']) as $key) {
// If there's a label they must provide at either a height or width.
if ($key != IMAGE_ORIGINAL && !empty($form['image_sizes'][$key]['label']['#value'])) {
if (empty($form['image_sizes'][$key]['width']['#value']) && empty($form['image_sizes'][$key]['height']['#value'])) {
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.'));
}
}