Search attachments in custom post type only

I think I’ve cracked it. Replace the top 14 lines of code with

Class SellMediaSearch {

private $query_instance;

/**
 * Init
 */
public function __construct(){
    add_filter( 'posts_join', array( &$this, 'terms_join' ) );
    add_filter( 'posts_search', array( &$this, 'search_where' ), 10, 2 );
    add_filter( 'posts_request', array( &$this, 'distinct' ) );
    add_filter( 'pre_get_posts', array( &$this, 'search_query' ) );
    add_filter( 'attachment_link', array( &$this, 'the_search_attachment_link' ), 10, 2 );
    add_filter( 'the_excerpt', array( &$this, 'the_search_excerpt' ) );
    add_filter( 'posts_where' , array( &$this, 'posts_where' ));
}


public function posts_where( $where ) {

    global $wpdb;
    if( is_search() ) {
                    $where .= ' AND ( post_type = \'sell_media_item\' OR ( post_type = \'attachment\' AND post_parent !=  0 ) ) ';
    }
    return $where;
}

Needs testing, but initially works for me. See github for more comments.