element-hq/element-web

Auto-upload images referenced by markdown as an easy CLI way to inline 'em

Opened this issue ยท 7 comments

Created by @ matthew:matrix.org.

๐Ÿ‘

Fil commented

we could start by changing the current behavior to display an "image anchor", rather than nothing.

i.e. if I type Hello ![](img url.jpg), display:

Hello ๐Ÿ“ธ <= this being a link

rather than

Hello

I just wrote up a feature request for this before realizing this issue exists, so I'll put what I wrote here as further motivation/rationale for such a feature.

Automatically upload external images when sent using Markdown syntax

Riot supports Markdown image syntax, but using it is currently cumbersome due to the requirement that the image URL must be an MXC URL (which is a valid requirement for privacy, especially in public rooms; see #4044). However, it makes pasting carefully formatted Markdown messages error-prone and requires manual steps (uploading the images manually, replacing the URLs).

As an example use case, I have a personal knowledge base composed of Markdown notes and I frequently paste such notes to people on Matrix. It works wonderfully except for the fact that images are silently stripped away.

However, I realized this could be fixed on the sender's side by making the sender's Riot automatically fetch the image from the external URL, uploading it to the homeserver and replacing the external URL with the MXC one before sending it. This would increase usability of Markdown image syntax drastically. Are there any downsides to this that I am missing?

Are there any downsides to this that I am missing?

A lot of the time CORS will disallow browsers from fetching the external resources

Will it? I often render my notes locally as HTML pages and open them in a browser and I don't think I've ever encountered images not loading due to CORS.

Loading the image in an img tag vs loading it in Javascript to access the data and upload is a different matter