--- new/imagefield.module	2008-05-28 11:49:37.000000000 +0200
+++ imagefield.module	2008-05-28 11:36:42.000000000 +0200
@@ -1,5 +1,5 @@
 <?php
-// $Id: imagefield.module,v 1.30.2.6.2.63 2008/05/11 23:28:46 dopry Exp $
+// $Id: imagefield.module,v 1.30.2.6.2.64 2008/05/13 00:02:02 dopry Exp $
 
 /**
  * @file
@@ -427,6 +427,15 @@
         '#description' =>
         t('The maximum allowed image size expressed as WIDTHxHEIGHT (e.g. 640x480). Set to 0 for no restriction. If a larger image is uploaded, it will be resized to reflect the given width and height.'),
       );
+      $form['min_resolution'] = array(
+        '#type' => 'textfield',
+        '#title' => t('Minimum resolution for Images'),
+        '#default_value' => $widget['min_resolution'] ? $widget['min_resolution'] : 0,
+        '#size' => 15,
+        '#maxlength' => 10,
+        '#description' =>
+        t('The minimum allowed image size expressed as WIDTHxHEIGHT (e.g. 160x120). Set to 0 for no restriction. Smaller image can not be upload.'),
+      );
       $form['max_filesize'] = array(
         '#type' => 'textfield',
         '#title' => t('Maximum filesize for Images'),
@@ -481,7 +490,7 @@
       break;
 
     case 'save':
-      return array('max_resolution', 'max_filesize', 'max_number_images', 'image_path', 'file_extensions', 'custom_alt', 'custom_title');
+      return array('max_resolution', 'min_resolution', 'max_filesize', 'max_number_images', 'image_path', 'file_extensions', 'custom_alt', 'custom_title');
   }
 }
 
@@ -886,6 +895,16 @@
       $valid = false;
     }
   }
+  
+  // If min resolution is set.
+  if ($field['widget']['min_resolution'] != '0') {
+    $image_info = image_get_info($file['filepath']);
+    list($min_widht,$min_height) = explode('x', $field['widget']['min_resolution']);
+    if($image_info['width'] < $min_widht || $image_info['height'] < $min_height){
+        form_set_error($fieldname .'_upload',t('Image resolution is too small (@widthx@height). Minimal resolution is @min_res.',array('@width' => $image_info['width'], '@height' => $image_info['height'], '@min_res' => $field['widget']['min_resolution'])));
+        $valid = false;
+     }
+   }
 
   // Is the mime type a match for image.
   if (strpos($file['filemime'], 'image/') !== 0) {
