The following handy snippet lets you remove files from your media library from the general search on your website. You can add the snippet to your plugin as usual, or to a solution such as the “Snippets” plugin.
add_action( 'init', 'osu_exclude_images_from_search_results' );
function osu_exclude_images_from_search_results() {
global $wp_post_types;
$wp_post_types['attachment']->exclude_from_search = true;
}




