Restrict role to view own media

There are plenty of solutions for limiting access to view your own uploaded media but I was wondering if it was possible to limit media to a user role ( e.g. author’s can see all other author’s media files).

If not, could it be possible to see all user’s uploaded media except the media uploaded by an admin?

Solutions Collecting From Web of "Restrict role to view own media"

You can restrict users to seeing only their own uploaded media with this piece of code:

Plugin Name: Manage Your Media Only
Version: 0.1

//Manage Your Media Only
function mymo_parse_query_useronly( $wp_query ) {
    if ( strpos( $_SERVER[ 'REQUEST_URI' ], '/wp-admin/upload.php' ) !== false ) {
        if ( !current_user_can( 'level_5' ) ) {
            global $current_user;
            $wp_query->set( 'author', $current_user->id );

add_filter('parse_query', 'mymo_parse_query_useronly' );