In this case the user has more work to do, as they will have to scale down the images on their own. You could filter the wp_handle_upload_prefilter
:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
add_filter('wp_handle_upload_prefilter', 'f711_image_size_prevent'); function f711_image_size_prevent($file) { $size = $file['size']; $size = $size / 1024; // Calculate down to KB $type = $file['type']; $is_image = strpos($type, 'image'); $limit = 5000; // Your Filesize in KB if ( ( $size > $limit ) && ($is_image !== false) ) { $file['error'] = 'Image files must be smaller than '.$limit.'KB'; } return $file; } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.