Post image won't be displayed after being downloaded to Discourse

@Arkshine sent me this solution that adds an empty space before an image:

add_filter('wp_discourse_excerpt', [$this, 'wp_discourse_excerpt'], 10, 1);

/**
 * Adds blank spaces above any <img> tag.
 * Purpose is to avoid Discourse failure to display markdown downloaded image.
 *
 * @param $post_content
 *
 * @return string
 */
public function wp_discourse_excerpt($post_content)
{
    $post_content = preg_replace('/(<img\s)/i', "\n\n$1", $post_content);
    $post_content = preg_replace('/[\n]{3,}/', "\n\n", $post_content);

    return $post_content;
}