Revision: 53644
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at November 30, 2011 10:57 by f6design
Initial Code
/** * Enforce minimum image upload size. */ add_filter('wp_handle_upload_prefilter','handle_upload_prefilter'); function handle_upload_prefilter($file) { $img=getimagesize($file['tmp_name']); $minimum = array('width' => '640', 'height' => '480'); $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 width is $width px."); } else { return $file; } }
Initial URL
Initial Description
Add this snippet to your Wordpress theme's functions.php file to reject any image uploads that are below the specified dimensions.
Initial Title
Enforce minimum image dimensions in Wordpress
Initial Tags
wordpress, images
Initial Language
PHP