You are here

function imagefield_crop_upload_validate in Imagefield Crop 7.3

Same name and namespace in other branches
  1. 7.2 imagefield_crop.module \imagefield_crop_upload_validate()

Validate function for images to be cropped. Returns an error if output resolution for field is set, but file is smaller.

Parameters

$file:

$field:

$instance:

Return value

array

File

./imagefield_crop.module, line 873

Code

function imagefield_crop_upload_validate($file, $field, $instance) {
  $errors = array();
  $widget_settings = $instance['widget']['settings'];
  $info = image_get_info($file->uri);
  if (!$info) {
    $errors[] = t('Image seems to be broken and can\'t be processed. Please try to upload another image or resave this current image with graphic editor');
  }

  //  TODO: Add validation of image resolution with preset support
  //  elseif ($info) {
  //    foreach($presets as $pid => $preset){
  //      if($preset->data['crop-type'] == 'resolution'){
  //        if ($info['width'] < $preset->data['resolution']['width'] || $info['height'] < $preset->data['resolution']['height']) {
  //          $errors[] = t('The image is too small for preset %preset; the minimum dimensions are %dimensions pixels.', array('%dimensions' => implode('x', $preset->data['resolution']), '%preset' => $preset->name));
  //        }
  //      }
  //
  //    }
  //  }
  return $errors;
}