// Exclude images from search results - WordPress
add_action( 'init', 'exclude_images_from_search_results' );
function exclude_images_from_search_results() {
global $wp_post_types;
$wp_post_types['attachment']->exclude_from_search = true;
}
source: https://presscustomizr.com/snippet/exclude-images-attachments-search-results/
]]>