function _image_field_resolution_validate
7.x image.field.inc | _image_field_resolution_validate($element, &$form_state) |
Element validate function for resolution fields.
1 string reference to '_image_field_resolution_validate'
- image_field_instance_settings_form in drupal-7.x/
modules/ image/ image.field.inc - Implements hook_field_instance_settings_form().
File
- drupal-7.x/
modules/ image/ image.field.inc, line 171 - Implement an image field, based on the file module's file field.
Code
function _image_field_resolution_validate($element, &$form_state) {
if (!empty($element['x']['#value']) || !empty($element['y']['#value'])) {
foreach (array('x', 'y') as $dimension) {
$value = $element[$dimension]['#value'];
if (!is_numeric($value)) {
form_error($element[$dimension], t('Height and width values must be numeric.'));
return;
}
if (intval($value) == 0) {
form_error($element[$dimension], t('Both a height and width value must be specified in the !name field.', array('!name' => $element['#title'])));
return;
}
}
form_set_value($element, intval($element['x']['#value']) . 'x' . intval($element['y']['#value']), $form_state);
}
else {
form_set_value($element, '', $form_state);
}
}