Brad, simply wrap the link around $caption
instead of appending to it. Replace this:
$caption .= ' ('. __('via') .' <a href="'. $source_url .'">'. $parts['host'] .'</a>)';
with
$caption = '<a href="'. esc_url ( $source_url ) .'">'. $caption .'</a>';