Wordpress - Media library - Limit images to custom post type

I'm not 100% sure if I get your problem right, but... Maybe this will help you...

Media uploader gets attachments with simple WP_Query, so you can use many filters to modify it's contents.

The only problem is that you can't query posts with specific CPT as parent using WP_Query arguments... So, we will have to use posts_where and posts_join filters.

To be sure, that we'll change only media uploader's query, we'll use ajax_query_attachments_args.

And this is how it looks, when combined:

function my_posts_where($where) {
    global $wpdb;

    $post_id = false;
    if ( isset($_POST['post_id']) ) {
        $post_id = $_POST['post_id'];

        $post = get_post($post_id);
        if ( $post ) {
            $where .= $wpdb->prepare(" AND my_post_parent.post_type = %s ", $post->post_type);
        }
    }

    return $where;
}

function my_posts_join($join) {
    global $wpdb;

    $join .= " LEFT JOIN {$wpdb->posts} as my_post_parent ON ({$wpdb->posts}.post_parent = my_post_parent.ID) ";

    return $join;
}


function my_bind_media_uploader_special_filters($query) {
    add_filter('posts_where', 'my_posts_where');
    add_filter('posts_join', 'my_posts_join');

    return $query;
}
add_filter('ajax_query_attachments_args', 'my_bind_media_uploader_special_filters');

When you open media uploader dialog while editing post (post/page/CPT), you'll see only images attached to this specific post type.

If you'd like it to work only for one specific post type (let's say pages), you'll have to change condition in my_posts_where function like so:

function my_posts_where($where) {
    global $wpdb;

    $post_id = false;
    if ( isset($_POST['post_id']) ) {
        $post_id = $_POST['post_id'];

        $post = get_post($post_id);
        if ( $post && 'page' == $post->post_type ) {  // you can change 'page' to any other post type
            $where .= $wpdb->prepare(" AND my_post_parent.post_type = %s ", $post->post_type);
        }
    }

    return $where;
}