Require Certain Size for User Image Upload
-
Hello!
I am trying to code for a specific image upload size. For example, I only want users to be able to upload images that are 800 x 800 px. Here is a code that I found for a MINIMUM upload size…add_filter(‘wp_handle_upload_prefilter’,’tc_handle_upload_prefilter’);
function tc_handle_upload_prefilter($file)
{$img=getimagesize($file[‘tmp_name’]);
$minimum = array(‘width’ => ‘800’, ‘height’ => ‘800’);
$width= $img[0];
$height =$img[1];if ($width < $minimum[‘width’] )
return array(“error”=>”Image dimensions are too small. Minimum width is {$minimum[‘width’]}px. Uploaded image width is $width px”);elseif ($height < $minimum[‘height’])
return array(“error”=>”Image dimensions are too small. Minimum height is {$minimum[‘height’]}px. Uploaded image height is $height px”);
else
return $file;
}But I need this to be equal to 800 x 800 px
Thanks for your help in advance!
- The topic ‘Require Certain Size for User Image Upload’ is closed to new replies.