1 image.field.inc | image_field_instance_settings_form_validate($element, &$form_state, $complete_form) |
Element validate handler for image_field_instance_settings_form().
File
- core/
modules/ image/ image.field.inc, line 227 - Implement an image field, based on the file module's file field.
Code
function image_field_instance_settings_form_validate($element, &$form_state, $complete_form) {
$min = $form_state['values']['instance']['settings']['min_dimensions'];
$max = $form_state['values']['instance']['settings']['max_dimensions'];
$min_dimensions = explode('x', $min) + array('', '');
$max_dimensions = explode('x', $max) + array('', '');
$min_dimensions_x = (int) $min_dimensions[0];
$min_dimensions_y = (int) $min_dimensions[1];
$max_dimensions_x = (int) $max_dimensions[0];
$max_dimensions_y = (int) $max_dimensions[1];
// Ensure that min dimensions are not set to be bigger than max dimensions,
// but only if max dimensions have been specified. This allows to set min
// dimensions, without having to restrict max dimensions.
if ((!empty($max_dimensions_x) && $min_dimensions_x > $max_dimensions_x) || (!empty($max_dimensions_y) && $min_dimensions_y > $max_dimensions_y)) {
form_set_error('instance][settings][min_dimensions', t('The minimum image dimensions cannot be bigger than its maximum dimensions.'));
}
}