A way to actually fix it without needing to depend from XWIKI-23398 is to actually not perform the clean up right away, but do it after the diff is displayed: that way we can hope that the request to get the image is performed through the sticky session of the user and so it gets the image properly from the temporary attachments of the same node where it was added. The clean up is then performed by an AJAX call.
But note that it still doesn't prevent issues such as CRAPP-390
This message was sent by Atlassian Jira (v9.3.0#930000-sha1:287aeb6)
If image attachments aren't displayed, see this article.