function _image_field_resolution_validate

Element validate function for resolution fields.

1 string reference to '_image_field_resolution_validate'
image_field_instance_settings_form in modules/image/image.field.inc
Implements hook_field_instance_settings_form().

File

modules/image/image.field.inc, line 171

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('Height and width values must be positive numbers.'));
                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);
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.