You are here

function _image_style_quality_form_quality_validate in Image Style Quality 7

This function validates the percentage input by a user to two conditions, it must be numeric and it must fall within 1 and 100.

1 string reference to '_image_style_quality_form_quality_validate'
image_style_quality_style_form in ./image_style_quality.module
The configuration form used to ask the user what quality their image should be.

File

./image_style_quality.module, line 72
This module is intended to allow users to set custom quality settings on individual image styles with no core hacks.

Code

function _image_style_quality_form_quality_validate($element, &$form_state, $form) {

  // Get the value entered by the user.
  $value = $element['#value'];

  // Make sure we are dealing with a number.
  if (!is_numeric($value)) {
    form_set_error('quality', t('Please enter a percentage as a single digit, eg "70"'));
  }

  // Make sure that number falls within a valid range.
  if ($value <= 0 || $value > 100) {
    form_set_error('quality', t('Please enter a percentage between 0 and 100.'));
  }
}