You are here

function imagefield_widget_settings_validate in ImageField 6.3

Implementation of CCK's hook_widget_settings($op = 'validate').

1 call to imagefield_widget_settings_validate()
imagefield_widget_settings in ./imagefield.module
Implementation of CCK's hook_widget_settings().

File

./imagefield_widget.inc, line 179
ImageField widget hooks and callbacks.

Code

function imagefield_widget_settings_validate($widget) {

  // Check that only web images are specified in the callback.
  $extensions = array_filter(explode(' ', $widget['file_extensions']));
  $web_extensions = array(
    'jpg',
    'jpeg',
    'gif',
    'png',
  );
  if (count(array_diff($extensions, $web_extensions))) {
    form_set_error('file_extensions', t('Only web-standard images (jpg, gif, and png) are supported through the image widget. If needing to upload other types of images, change the widget to use a standard file upload.'));
  }

  // Check that set resolutions are valid.
  foreach (array(
    'min_resolution',
    'max_resolution',
  ) as $resolution) {
    if (!empty($widget[$resolution]) && !preg_match('/^[0-9]+x[0-9]+$/', $widget[$resolution])) {
      form_set_error($resolution, t('Please specify a resolution in the format WIDTHxHEIGHT (e.g. 640x480).'));
    }
  }
}