You can strip images on display pretty easily.
add_filter(
'comment_text',
function($comment) {
$allowed_html = array(
'a' => array(
'href' => array(),
'title' => array()
),
'br' => array(),
'em' => array(),
'strong' => array()
);
return wp_kses($comment, $allowed_html);
}
);
That will strip any tags not listed in the provided array. To specifically strip images with links to external sources you need something more complicated.
function strip_external_images($match) {
if (empty($match)) return;
$site = parse_url(get_site_url());
$parsed = parse_url($match[1]);
if (empty($parsed['host']) || $site['host'] !== $parsed['host']) {
return '';
} else {
return $match[0];
}
}
add_filter(
'comment_text',
function($comment) {
$pattern = '|<img.*src="https://wordpress.stackexchange.com/questions/113762/([^"]*)"[^>]+>|';
return preg_replace_callback($pattern,'strip_external_images',$comment);
}
);
That should allow users to add images to comments but only images hosted at same domain as the site itself.