Broken pasted from email image in post?

AI-generated summary

Broken pasted from email image in post?

A user reported an issue where an image pasted from an email into a Discourse post is broken. Canapin noticed that the image works in the message preview but breaks after posting.

Canapin also mentioned that the download remote images to local setting is enabled, but the image still breaks. codinghorror explained that email providers often have aggressive image hotlink prevention, which prevents the image from being used outside the webmail domain.

Canapin and Arkshine expressed interest in finding a way to circumvent this issue. Stephen clarified that copy-pasting an image link from webmail won’t work because the Discourse server isn’t authenticated to access the asset. However, pasting the image itself, rather than the link, might work.

Hi.
One of my users pasted an email message into a Discourse post:

The image doesn’t work:

However, it works in the message preview:


Here’s the generated markdown code :

![](https://webmail1m.orange.fr/webmail/fr_FR/tinyMCE/plugins/emotions/img/animes/complice.gif)

Here’s the produced HTML code:

<p>C’est de l’ancien (donc de l’historique), alors il faut se remettre dans le contexte, une montagne pas très connue, ça bouge pas trop… <span alt="" class="broken-image" title="Cette image ne fonctionne pas"><svg class="fa d-icon d-icon-unlink svg-icon" aria-hidden="true"><use xlink:href="#unlink"></use></svg></span></p>

The image shows up if I rebuild the HTML, but it will be broken again after a while.

download remote images to local setting is enabled.

Any idea why the image breaks?

This is usually because email providers have very aggressive image hotlink prevention, they do not want people using email image URLs anywhere outside their webmail domain.

Thanks for the explanation.

Any way to circumvent that?

Since my forum is supposed to download external pictures, I’d expect that it actually download the picture to display it, but I don’t know how it works for websites that prevent hotlinking. :man_shrugging:t6:

Oh, it happens on my forum too. I thought it was due to my late database manipulation! :smile:
Actually, I believe it’s the first time I see “broken” images. Any improvement on this behavior would be welcomed.

Webmail links will work in the preview as the local browser already has a copy.

Copy + paste won’t work unless you can find a way to paste the image itself, rather than a link to the image. Links will never work because your discourse server isn’t authenticated to the Webmail, so can’t access the asset.