Limit the number of uploaded files per upload

How to limit the number of uploaded files per upload for everyone else except super admin?

The code bellow works while uploading images through Post and Page, but not from Media Library

add_filter('wp_handle_upload_prefilter', 'limit_wp_handle_upload_prefilter');
function limit_wp_handle_upload_prefilter($file) {
// This bit is for the flash uploader
if ($file['type']=='application/octet-stream' && isset($file['tmp_name'])) {
$file_size = getimagesize($file['tmp_name']);
if (isset($file_size['error']) && $file_size['error']!=0) {
$file['error'] = "Unexpected Error: {$file_size['error']}";
return $file;
} else {
$file['type'] = $file_size['mime'];
if ($post_id = (isset($_REQUEST['post_id']) ? $_REQUEST['post_id'] : false)) {
if (count(get_posts("post_type=attachment&post_parent={$post_id}"))>3)
$file['error'] = "Sorry, you cannot upload more than four (4) image.";
return $file;

The code is limited to 4 images per upload.

Please advise how to make it work in Media Library > Add New and apply to all users except super admin.

Kind regards,