Add this code to your theme’s functions.php file, and it will limit image dimentions
add_filter('wp_handle_upload_prefilter','tc_handle_upload_prefilter');
function tc_handle_upload_prefilter($file)
{
$img=getimagesize($file['tmp_name']);
$minimum = array('width' => '600', 'height' => '900');
$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;
}
Related Posts:
- Custom image size in Media Dropdown
- Images uploaded using media uploader are appearing upside down
- Disable auto-resizing of uploaded images, but only for certain filename
- Can’t generate thumbnail images
- Is it possible to limit number of files a non-admin user can upload via the WordPress media library?
- Zip all (original) images from media gallery
- How to overwrite image if it already exists – WordPress, Gravity form
- Missing feature image link function
- Upload Multiple Files With media_handle_upload
- How to change the markup WordPress inserts for post images
- How to get the image EXIF date/time and use it for the WP post date/time
- Programmatically Set First Image as Featured
- How to use get_template_directory_uri() to load an image that is in a sub-folder of my theme?
- WP 4.4. responsive loads normal image after loading the responsive image
- How to register images uploaded via FTP in media library?
- How to add classes to images based on their categories?
- delete uploaded file
- How to reduce original image quality on upload?
- Is it possible to maintain image aspect ratio when scaling images?
- Set image size on media and text block with a function
- Generating Responsive Background Image Sizes in PHP
- Max file size not updating
- Create thumbnail on PDF upload with Gravity Forms
- Remove images from get_the_excerpt
- Use Exact Image Size using add_image_size
- How to add a rel attribute to images that contains their categories?
- Display height and width properties with the_post_thumbnail() or related function
- Insert width & height attributes to all images displayed on each page
- Allowing SVG uploads in media uploader without plug-in
- Removing the first image in content
- Function to auto-set a featured image that is already in use
- Actions according to image type and size
- Woocommerce Storefront WordPress Ignore Media Gallery Images and use External 3rd Party Host
- Overwrite Parent Theme add_image_size in Child Theme
- How to add css class to image attached in all the posts?
- How can I enable uploading excel files?
- Add custom image size not working
- How can you limit srcset on a single type of page?
- Convert all images to PNG on file upload
- how to add an image to the footer?
- wp_get_attachment_image function size argument not working if I also add a custom class
- WordPress upload_mimes not working for front-end uploads of 3D files
- Understanding and altering the structure of posted images
- Publish/Update post is changing image links from file url to post url
- Featured Image Thumbnail Creation
- Twentyten Child Theme: header images display messed up in admin panel
- Display images that are not in the content
- Can you put a condition on add_image_size() depending on the width of the uploaded image?
- show first 3 thumbnails of posts in different sizes [closed]
- Remove after images
- Getting custom image size URL in functions
- Redirect to another page using contact form 7? [closed]
- Control the srcset much more (not all sizes in it each time)
- Limit dimensions of “Full” size images
- How to hide image-url if no attachment?
- How to stop media_sideload_image from running when deleting a post?
- Possible to hook into Media Library preview File column and use a custom image?
- What are the meta fields for an attachment?
- How to properly set custom logo size?
- Add attribute only to first image of every post via functions.php
- Need To Change WordPress Meta Tags… Includes wordpress shortcodes
- How to Add Shortcode to html img code?
- How to add a new image size and apply it to posts only?
- Function to insert missing image size attributes into img tags
- Image Crop Not Working
- Use existing image sizes for WooCommerce
- Function that prevents users from uploading photos more photos
- Problem in using Customizer
- wp_get_attachment_image_src returns image on main domain, false on subdomain
- Retrieve First Image Function
- Custom Image Size in Insert Media
- Featured Image keeps cropping
- Prevent creating multiple image resizes in twentytwelve template
- Conditional function for excluding first image from content, not working
- get_image_tag() html output : empty src attribute
- Need To Resize Images Exactly Without Losing Image Details
- Different image using srcset function
- Auto delete content in specific folder inside media library
- How to update an image attachment’s alt text from a custom field when saving a post?
- large image size of 1440×1440 not pulling 2x of 2880×2880 image
- Can You Set A Minimum Image Dimension For Resizing Images?
- blank page with wp_get_attachment
- (Divi): How to make WordPress load images of specific size for Blurb modules on given page with a funciton?
- Images with overlay
- Featured image on archive page based on post type
- Function image_send_to_editor returns emty title tag
- Using Switch Statement to Change Image According to Last Digit of Topic ID
- Disable links to images only if link is an image
- Restricted images only for logged user. (hidden url)
- No compression occurs on my jpegs after adding jpeg_quality hook to my functions.php file
- Different body image backgrounds on different pages, posts and categories
- Update add_image_size
- Figure inlined width trigger distorted layout
- wp_upload_bits – define (sub)folder / (sub)directory before filename?
- Open image size links in a page instead of direct image link
- Full size image option removing problem
- Function to get thumbnail img source
- How to resize image from import image url?
- How to add height and width dimensions automatically to archive descriptions
- Convert Image to Webp on upload without plugin