Only Show Current User’s Media Attachments

 

/*
 * Only Show Current User's Media Attachments
 */

function show_current_user_attachments( $query = array() ) {
    $user_id = get_current_user_id();

    if ( $user_id ) {
        $query[ 'author' ] = $user_id;
    }

    return $query;
}

add_filter( 'ajax_query_attachments_args', 'show_current_user_attachments', 10, 1 );