WP Minimum Image Upload Size

WP Minimum Image Upload Size

WordPress Plugin that validates images. Configure minimum image upload size on the settings page for post types and custom fields.

Current Version: 0.1.0

Github Page:https://github.com/justinwhall/wordpress-min-image-upload-size


WordPress’ add_image_size() function is great. There is however, one problem. Take, for instance, the following function.

function my_theme_setup() {
add_theme_support( ‘post-thumbnails’ );
add_image_size( ‘slider’, 1500, 800, true );

add_action( ‘after_setup_theme’, ‘my_theme_setup’ );

Just like that WordPress will process and save an additional image  1500 x 800 to the wp-uploads directory assuming the image is larger than 1500 x 800. Much to my dismay, I’ve explained more times than I can count that one can crop and images “larger” than its current dimensions.

How does WordPress handle this? It simply doesn’t do anything. In this case if a user would upload an image that was, say, 500 x 500 WordPress would check the image dimensions of the users uploaded images, determine that was smaller than the add_image_size( 'slider', 1500, 800, true ) and just skip processing and saving an image of this size.

The problem is then when theme goes to use the image. Theme might do something like this:echo the_post_thumbnail( 'slider' );

You’d expect an image of 1500 x 800 dimensions. If that size exists, you’ll get it – otherwise you’ll get the original. WP Minimum Image Size addresses that problem by adding an options page where minimum upload dimensions can be configured for different post types and custom fields including support for for advanced custom fields.

Screenshot 2015-08-12 16.38.17


instance, the following function..