function image_style_name_validate

image_style_name_validate($element, $form_state)

Element validate function to ensure unique, URL safe style names.

This function is no longer used in Drupal core since image style names are now validated using #machine_name functionality. It is kept for backwards compatibility (since non-core modules may be using it) and will be removed in Drupal 8.

File

modules/image/image.admin.inc, line 291
Administration pages for image settings.

Code

function image_style_name_validate($element, $form_state) {
  // Check for duplicates.
  $styles = image_styles();
  if (isset($styles[$element['#value']]) && (!isset($form_state['image_style']['isid']) || $styles[$element['#value']]['isid'] != $form_state['image_style']['isid'])) {
    form_set_error($element['#name'], t('The image style name %name is already in use.', array('%name' => $element['#value'])));
  }

  // Check for illegal characters in image style names.
  if (preg_match('/[^0-9a-z_\-]/', $element['#value'])) {
    form_set_error($element['#name'], t('Please only use lowercase alphanumeric characters, underscores (_), and hyphens (-) for style names.'));
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!image!image.admin.inc/function/image_style_name_validate/7.x