You are here

function imagecrop_validate_aspect in Image javascript crop 6

Same name and namespace in other branches
  1. 7 includes/imagecrop.effects.inc \imagecrop_validate_aspect()

Validation of the aspect ratio entry

1 string reference to 'imagecrop_validate_aspect'
imagecrop_javascript_form in ./imagecrop_actions.inc
@file Imagecache actions implementation.

File

./imagecrop_actions.inc, line 90
Imagecache actions implementation.

Code

function imagecrop_validate_aspect(&$element, &$form_state) {
  if (!is_numeric($element['#value'])) {
    if (strtolower($element['#value']) != 'keep' && strtolower($element['#value']) != 'crop') {
      if (!empty($element['#value'])) {
        drupal_set_message(t('Aspect ratio must be a number, the string KEEP, CROP, or empty if you don\'t want to fix it. Defaulting to empty.'));
      }
      form_set_value($element, FALSE, $form_state);
    }
    else {
      form_set_value($element, strtoupper($element['#value']), $form_state);
    }
  }
  else {
    form_set_value($element, abs((double) $element['#value']), $form_state);
  }
}