I did a googles of the issue (using ‘wordpress restrict media access’) and got this link on the first page https://www.wpbeginner.com/plugins/how-to-restrict-media-library-access-to-users-own-uploads-in-wordpress/
Which has this code
// Limit media library access
add_filter( 'ajax_query_attachments_args', 'wpb_show_current_user_attachments' );
function wpb_show_current_user_attachments( $query ) {
$user_id = get_current_user_id();
if ( $user_id && !current_user_can('activate_plugins') && !current_user_can('edit_others_posts
') ) {
$query['author'] = $user_id;
}
return $query;
}
If the user doesn’t have post edit or admin capability, then they won’t see anything on the Media screen in Admin. You can modify the code to check for a specific user group (admin only, for example), or a specific user.
There are other solutions found via the same googles/bing/duck search.