Here you go:
if(!current_user_can('delete_others_posts')){
/*Handling wp media uloads*/
add_filter('wp_handle_upload_prefilter','lets_handle_img_width');
function lets_handle_img_width($file)
{
$img = getimagesize($file['tmp_name']);
$width = $img[0];
if ($width < 350){
$file['error'] = "Image is small too small. Get something of width more than 350px.";
}
return $file;
}
}
Check official documentation about wp_handle_upload_prefilter.
Related Posts:
- WordPress adding scaled images that don’t exist (1536×1536 and 2048×2048)
- Download an image from a webpage to the default uploads folder
- Is there a hook which fires after all thumbnails are generated?
- Featured image shortcode
- How to find attachment by it’s name?
- Change WordPress image URLs via filter
- get_the_post_thumbnail_url with an unregistered size
- Cropped featured image replaces original image in gallery
- Image Scaling using get_the_post_thumbnail issue in WordPress
- Any easy way to automatically set the first inline image in a post as the thumbnail?
- How to create thumbnails with a fixed width, so all of them will have the same width?
- Programatically creating image attachments from local URLs and setting featured image
- How can I add the “Use as featured image” to a custom metabox?
- set_post_thumbnail_size not cropping featured images, but reducing proportionally
- How to output placeholder image if no featured image set?
- Featured Images on Front Page
- Download button for Featured Image in every post – automatically
- Show prev and next post links for parent post of current image in attachment page?
- Setup A Default Featured Image
- Find posts without featured image? [duplicate]
- How do I add a featured image to a single post page?
- Add a featured image in my theme?
- Disable wordpress image sizes generation
- Featured Image .svg height and width 1px only
- How to check if user is uploading/setting an image as a featured image?
- Images are randomly deleted from server
- Frontend Post – Allow Only Image File Upload
- Images not working using Featured post
- Add instructions to featured image
- How do I get more image editing options in the admin?
- Thumbnails are bigger in size than the original image
- Lazyload post thumbnails
- Exclude featured image from gallery in wp-admin
- Featured images not displaying at full resolution
- Woocommerce featured image of page – not product
- Can’t seem to attach uploaded image to post and set it as thumbnail
- Big Image on Featured Post, Normal on Single Post
- offload media to external services [closed]
- Store Snapshot created via wordpress to use with lightbox
- How to stop thumbnail generation from some images and different size thumbnail generate
- Update old Post image metadata to ‘thumbnail’ wp_attached_file
- How to stop wordpress always displaying full-res images
- WP keeps looking up post thumbnail on https even though wp-config says http
- WordPress PNG compression issue
- How to replace images?
- Custom Loop, Match Category with Page: How to display post featured image?
- How do I get my main image to stretch the full length of the screen?
- Custom responsive ‘featured image’ sizes
- the_post_thumbnail(‘medium’) setting some images width=1 height=1
- What can i do add title to ‘large’ image?
- Retrieve Image Attachments Getting Post Thumbnail Image First
- Height and width attribute not setting by the_post_thumbnail
- How to display original unmodified thumbnail
- How to set minimum required size for featured image?
- How to set featured image from external url programmatically
- All Images not calling alt text
- Hide Featured Image box – isn’t working?
- Can we use featured image as third party website image URL
- Show (print) featured image all dimensions (height, width)
- add_image_size not working
- Serve different images per screen size and cache possible?
- Set two default featured images
- Product Images Low Quality After Updating From WP 3.5 to 4 [closed]
- adding image to post thumbnail from another server
- Set Featured Image not opening – Stuck at loading
- Convert featured images into “product images”
- Resize uploaded images [duplicate]
- resize and crop thumbnail photos
- How to use the thumbnail size with catch_that_image
- my featured image of wordpress are not showing in the front end though image are uploaded in media library
- How to change Gallery image url in product page ? In function.php?
- Custom image size not displaying with wp_get_attachment_image()
- How to use default image as featured image by implement some code in function.php
- WordPress Multisite: Images moved to /sites/1?
- How to delete original image file after upload and resize
- attachment_fields_to_save first parameter is null
- An error has occurred during the upload process in wordpress version 5.3.2
- Show featured image in all posts
- Image alt attribute
- I cannot upload images to post or the media library in wordpress
- Images missing from Blog post page
- Custom Background for each page and post
- second featured post not displaying on page [closed]
- Using custom field to change alt text for a featured image
- Delete post if featured image is smaller than Y pixels by Y pixels
- How to display image thumbnails on the search results page?
- Get custom size of thumbnails
- Url link to feature image in the portfolio [closed]
- How do I get resized thumbnails?
- Making a thumbnail if there exist a link with. jpg or .png extension in WordPress
- Why is WordPress loading a different sized post thumbnail?
- Title image is missing ( but is not the WP 3.5 issue )
- Images will not attach to posts after site migration
- Using the on-board image editor for featured images: edits are not being used
- Tried everything but Facebook share button won’t load the post thumbnail
- WP is showing wrong image dimensions
- Why some images are not allowed to be edited only for thumbnails?
- How to import external media items into wordpress media library (without using storage)
- How can I use an image from an external source without uploading it to the media library
- Is there a way to upscale a media library original image to the nearest whole pixel in WordPress?