You are here

function imce_profile_validate in IMCE 6.2

Same name and namespace in other branches
  1. 7 inc/imce.admin.inc \imce_profile_validate()

Profile form validate.

1 string reference to 'imce_profile_validate'
imce_profile_form in inc/imce.admin.inc
Profile form.

File

inc/imce.admin.inc, line 305
Serves administration pages of IMCE.

Code

function imce_profile_validate($form, &$form_state) {
  $profile =& $form_state['values']['profile'];
  $dim_re = '/^\\d+x\\d+$/';
  $dim_error = t('Dimensions must be specified in <kbd>WIDTHxHEIGHT</kbd> format.');

  // Check max image dimensions
  if ($profile['dimensions'] && !preg_match($dim_re, $profile['dimensions'])) {
    return form_set_error('profile][dimensions', $dim_error);
  }

  // Check thumbnails dimensions
  foreach ($profile['thumbnails'] as $i => $thumb) {
    if (trim($thumb['name']) != '' && !preg_match($dim_re, $thumb['dimensions'])) {
      return form_set_error("profile][thumbnails][{$i}][dimensions", $dim_error);
    }
  }
}