/ Published in: PHP

Add this snippet to your Wordpress theme's functions.php file to reject any image uploads that are below the specified dimensions.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/** * Enforce minimum image upload size. */ add_filter('wp_handle_upload_prefilter','handle_upload_prefilter'); function handle_upload_prefilter($file) { $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; } }
Comments
