Remove images from the_content [duplicate]

Your function is not removing the p tags: they have not yet been added as get_the_content returns the unfiltered content. You can manually add the p tags using wpautop.

$unfiltered = preg_replace('/<img[^>]+\>/i', '',get_the_content());
$filtered = wpautop($unfiltered);

echo $filtered;