Is there a way to prompt an editor whenever they try to upload an image smaller than 350px width? Essentially rejecting any image uploads that are smaller than 350px width?
Thanks
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.
Sign up to join this communityIs there a way to prompt an editor whenever they try to upload an image smaller than 350px width? Essentially rejecting any image uploads that are smaller than 350px width?
Thanks
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.
if ($width < 350){ $file['error'] = "Image is small too small. Get something of width more than 350px.";
return $file; }
– BillK
Feb 7 '16 at 0:49