element-hq / element-meta

Shared/meta documentation and project artefacts for Element clients
72 stars 12 forks source link

Embed direct links to images when using URL Previews #1099

Open throwabird opened 3 years ago

throwabird commented 3 years ago

Your use case

Currently the URL preview can display the image If a link directly points to it. In that particular case the URL preview does not provide any additional information other then the Image itself which is why I propose that the Image should be directly embedded (as if it was sent as a file) similar to how Discord does it.

Examples: Discord Embed Discord_Embed

Element Embed Element_Embed

Image used :): https://unsplash.com/photos/La2kOu2dmH4

Have you considered any alternatives?

No response

Additional context

On a side note: In case the image is embedded I think the full image should be displayed instead of the preview version. This would allow GIFs to also be embedded as such and not just as a single image since currently if you send a GIF you get a preview of it and only if you press to view the full size version you get the actual moving GIF.

JoaCHIP commented 1 year ago

For an example of how this could work, see Discord which already does this. (Uploading an image is shown precisely the same way as a direct link to an image file.)

With the current solution, people will be tempted to upload images instead of just linking in order to get the bigger preview, and this is a waste of disk space.

jellykells commented 1 year ago

For an example of how this could work, see Discord which already does this. (Uploading an image is shown precisely the same way as a direct link to an image file.)

With the current solution, people will be tempted to upload images instead of just linking in order to get the bigger preview, and this is a waste of disk space.

URL previews are handled by the server currently so if this feature was implemented the image would be using disk space on the server either way. media associated with URL previews could be pruned after some period of time but that would make images shared this way unintentionally ephemeral (e.g. if the link is no longer valid)

obj-obj commented 1 year ago

For an example of how this could work, see Discord which already does this. (Uploading an image is shown precisely the same way as a direct link to an image file.) With the current solution, people will be tempted to upload images instead of just linking in order to get the bigger preview, and this is a waste of disk space.

URL previews are handled by the server currently so if this feature was implemented the image would be using disk space on the server either way. media associated with URL previews could be pruned after some period of time but that would make images shared this way unintentionally ephemeral (e.g. if the link is no longer valid)

The client could be the one automatically fetching and displaying images (I'm pretty sure the embedding on discord is handled client-side, and the data on the server is just the link)

URL previews are already client-side in encrypted rooms, anyway

t3chguy commented 1 year ago

URL previews are already client-side in encrypted rooms, anyway

No they're not. Element clients don't expose your IP and in the web CORS is an issue.

obj-obj commented 1 year ago

URL previews are already client-side in encrypted rooms, anyway

No they're not. Element clients don't expose your IP and in the web CORS is an issue.

How are they handled, then? The server can't ever know what the url is to add a preview, as it's encrypted, so does the sender attach the preview?

t3chguy commented 1 year ago

How are they handled, then? The server can't ever know what the url is to add a preview, as it's encrypted, so does the sender attach the preview?

The server never attaches a preview, clients conditionally ask for previews using the API if they wish to. Element clients make you opt-in to url previews in each E2E room for this purpose. https://spec.matrix.org/v1.6/client-server-api/#get_matrixmediav3preview_url

jellykells commented 1 year ago

The client could be the one automatically fetching and displaying images (I'm pretty sure the embedding on discord is handled client-side, and the data on the server is just the link)

Matrix doesn't work this way and I don't think it should. It enables targeted malicious and unwanted behaviour by third parties such as automated IP grabbing, user profiling, link graphing, etc. I think the benefits of server-side URL preview generation outweigh the caveats (namely requiring trust between the client and server, and there are ways to improve on that).

obj-obj commented 1 year ago

How are they handled, then? The server can't ever know what the url is to add a preview, as it's encrypted, so does the sender attach the preview?

The server never attaches a preview, clients conditionally ask for previews using the API if they wish to. Element clients make you opt-in to url previews in each E2E room for this purpose. https://spec.matrix.org/v1.6/client-server-api/#get_matrixmediav3preview_url

Ah, makes sense