set a minimim upload resolution set a minimim upload resolution
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

set a minimim upload resolution

Started by nickfzx, March 15, 2007, 06:30:23 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

nickfzx

I have searched and looked but can't seem to find anything.

Is there a way, or a mod that allows admin to set a minimum upload size for images?

Nibbler

I don't know of any mod, just look through upload.php for the maximum dimensions check and add a corresponding minimum dimensions check.

nickfzx

ok I have figured this out...of course you were exactly right Nibbler

ok if anyone else wants to have the option to set a minimum resolution of images this is how you do it:

first open you database and insert a new row like so:       (alter your db prefix accordingly)
INSERT INTO `cpg_config` (`name`, `value`) VALUES ('min_upl_width_height', '200');

now open your language file (I'm going to assume it's english.php)

open english.php

find:
  array('Max width or height for uploaded pictures/videos (pixels)', 'max_upl_width_height', 0, 'f=index.htm&as=admin_picture_thumbnail_max_upload_dimension&ae=admin_picture_thumbnail_max_upload_dimension_end'), //cpg1.4
after add:
  //mod for MIN UPLOAD START
   array('Min width or height for uploaded pictures/videos (pixels)', 'min_upl_width_height', 0, 'f=index.htm&as=admin_picture_thumbnail_min_upload_dimension&ae=admin_picture_thumbnail_min_upload_dimension_end'), //cpg1.4
   //MOD from MIN UPLOAD END

find:
  'pixel_allowance' => 'The height and or width of the uploaded picture is more than that allowed by the gallery config.', //cpg1.4
after add:
  'min_pixel_allowance' => 'The height and or width of the uploaded picture is less than that allowed by the gallery config.',

open upload.php
find:
// Check that picture size (in pixels) is lower than the maximum allowed. If not, delete it.
                } elseif (max($imginfo[0], $imginfo[1]) > $CONFIG['max_upl_width_height']) {
                  if ((USER_IS_ADMIN && $CONFIG['auto_resize'] == 1) || (!USER_IS_ADMIN && $CONFIG['auto_resize'] > 0)) //($CONFIG['auto_resize']==1)
                  {
                    //resize_image($uploaded_pic, $uploaded_pic, $CONFIG['max_upl_width_height'], $CONFIG['thumb_method'], $imginfo[0] > $CONFIG['max_upl_width_height'] ? 'wd' : 'ht');
                    resize_image($uploaded_pic, $uploaded_pic, $CONFIG['max_upl_width_height'], $CONFIG['thumb_method'], $CONFIG['thumb_use']);
                  }
                  else
                  {
                    @unlink($path_to_image);

                    // The file upload has failed -- the image dimensions exceed the allowed amount.
                    $file_failure_array[] = array( 'failure_ordinal'=>$failure_ordinal, 'file_name'=> $file_name, 'error_code'=>$lang_upload_php['pixel_allowance']);

                    // There is no need for further tests or action, so skip the remainder of the iteration.
                    continue;
                  }
                }

after ad:
//mod to set min resolution //reversed
elseif (max($imginfo[0], $imginfo[1]) < $CONFIG['min_upl_width_height']) {

                    @unlink($path_to_image);

                    // The file upload has failed -- the image dimensions are smaller than the allowed size.
                    $file_failure_array[] = array( 'failure_ordinal'=>$failure_ordinal, 'file_name'=> $file_name, 'error_code'=>$lang_upload_php['min_pixel_allowance']);

                    // There is no need for further tests or action, so skip the remainder of the iteration.
                    continue;
}
//end of mod to set min resolution


find:
                // Check that picture size (in pixels) is lower than the maximum allowed. If not, delete it.
                } elseif (max($imginfo[0], $imginfo[1]) > $CONFIG['max_upl_width_height']) {
                    @unlink($path_to_image);

                    // The file upload has failed -- the image dimensions exceed the allowed amount.
                    $URI_failure_array[] = array( 'failure_ordinal'=>$failure_ordinal, 'URI_name'=> $_POST['URI_array'][$counter], 'error_code'=>$lang_upload_php['pixel_allowance']);

                    // There is no need for further tests or action, so skip the remainder of the iteration.
                    continue;
                }

after add:
// MIN PIXEL MOD HERE //reversed
elseif (max($imginfo[0], $imginfo[1]) < $CONFIG['min_upl_width_height']) {
                    @unlink($path_to_image);

                    // The file upload has failed -- the image dimensions exceed the allowed amount.
                    $URI_failure_array[] = array( 'failure_ordinal'=>$failure_ordinal, 'URI_name'=> $_POST['URI_array'][$counter], 'error_code'=>$lang_upload_php['min_pixel_allowance']);

                    // There is no need for further tests or action, so skip the remainder of the iteration.
                    continue;
                }
// END OF MIN PIXEL MOD


If you go into config you will see a new option below max resolution called min resolution.  It is set to 200 by default.

That should do it, I have tested this with a admin and member account and also with too large, too small and correct midrange images and have found no errors.

Nibbler

Great, thanks for contributing your changes.