-
Notifications
You must be signed in to change notification settings - Fork 446
MSC4475: Media galleries by inline MXC links #4475
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
MurzNN
wants to merge
2
commits into
matrix-org:main
Choose a base branch
from
MurzNN:media-galleries-by-inline-mxc-links
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+163
−0
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,163 @@ | ||
| # MSC4475: Media galleries by inline MXC links | ||
|
|
||
| Users need an easy way to send multiple images together with their text message | ||
| to represent them as a gallery in a single message. The same is true for files | ||
| and other attachment types. | ||
|
|
||
| Currently, most Matrix clients allow sending only a single file (image) together | ||
| with a text message, which is not sufficient in many cases. Some clients provide | ||
| a composer UI that appears to attach multiple images, but those images are | ||
| actually sent as separate messages. | ||
|
|
||
| This proposal describes a convenient and flexible way to attach multiple images | ||
| and other files into a single message using inline MXC links. | ||
|
|
||
| ## Proposal | ||
|
|
||
| There are three different popular approaches to handle multiple media in a | ||
| single message: | ||
|
|
||
| 1. Multiple media file above with a single caption text below: WhatsApp, | ||
| Telegram. | ||
| 2. Message text above with multiple media attachments below: Slack. | ||
| 3. Message text with inline media: Microsoft Teams, Skype. | ||
|
|
||
| Pros and cons of these approaches are described in the section "Alternatives". | ||
|
|
||
| This proposal describes approach 3, which covers approaches 1 and 2. | ||
|
|
||
| The Matrix protocol already allows inline links to Matrix media files using MXC | ||
| URIs; here is an example: | ||
| ```html | ||
| Check out my photos from FOSDEM 2025: | ||
| <img src="mxc://example.org/JWEIFJweifjWIeifj" /> | ||
| <img src="mxc://example.org/JWEIFJweifjWIeifk" /> | ||
| <img src="mxc://example.org/JWEIFJweifjWIeifl" /> | ||
|
|
||
| And especially look at this awesome group photo: | ||
| <img src="mxc://example.org/JWEIFJweifjWIeifm" /> | ||
|
|
||
| What a nice day at FOSDEM 2025! | ||
| ``` | ||
|
|
||
| This is sufficient to implement message galleries, so we don't need any | ||
| server-side changes to use this approach. | ||
|
|
||
| ### Client-side rendering | ||
|
|
||
| Matrix clients should consider messages with images that reference Matrix media | ||
| via MXC URIs as messages containing an inline gallery. | ||
|
|
||
| To display the media in the timeline, clients should use media thumbnails from | ||
| the Media API and present them as a grid: two per row on narrow screens (for | ||
| example, mobile), with more columns on wider timelines. | ||
|
|
||
| By the click on the media, clients should show a listable gallery of full-sized | ||
| images / videos from the current message. Optionally, they can also allow | ||
| listing images from other messages too. | ||
|
|
||
| #### Text-only rendering | ||
|
|
||
| Text-only clients should render the message with plaintext links in the square | ||
| brackets displaying the alt text of the link, falling back to the media filename | ||
| (Content-Disposition value), and the media url as the last resort. | ||
|
|
||
| #### Fallback for clients without support | ||
|
|
||
| Clients, that do not support this feature, will render the message as just a | ||
| text with MXC links to media fiels, that is a sufficient for the fallback. | ||
|
|
||
| ### Client-side composing | ||
|
|
||
| In the message composer, clients should allow inserting files (images, videos, | ||
| other files) inline within the message text in the current cursor position. | ||
|
|
||
| Files can be pasted by a file chooser, from the clipboard, inserted by drag and | ||
| drop. | ||
|
|
||
| GUI clients can render these inline as thumbnails directly in the message | ||
| composer. | ||
|
|
||
| Plaintext-based composers can use a textual representation of the MXC link, like GitLab and Github composers do. | ||
|
|
||
| ### Server-side link tracking | ||
|
|
||
| It is useful to explicitly track the media links referenced in a message, | ||
| especially for encrypted messages where the server cannot inspect message | ||
| content to discover links. | ||
|
|
||
| This could be implemented via an additional array of links in the message | ||
| object, but we'll keep that out of scope and describe it in a separate MSC. | ||
|
|
||
| ## Potential issues | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This proposal will only work with unencrypted images from what I understand? |
||
|
|
||
| None identified. | ||
|
|
||
| ## Alternatives | ||
|
|
||
| When a user wants to attach an image to the message, there are usually two | ||
| intentions: | ||
|
|
||
| **Intention 1**: Show the image as the main message content, and, optionally, | ||
| add some comment to the image. | ||
|
|
||
| **Intention 2**: Show the text as the main message content, and attach an image | ||
| to it as context. | ||
|
|
||
| These are two different purposes for sending images, and this proposal covers | ||
| both of them. | ||
|
|
||
| In the result, we have three popular approaches to handle multiple media in a | ||
| single message: | ||
|
|
||
| 1. Text below the images. | ||
|
|
||
| Used in messengers: Slack. | ||
|
|
||
| If we display the message text below the images, the main content of the message | ||
| will be the images, and the "body" will be just a commenting text, in addition | ||
| to the images. | ||
|
|
||
| 2. Text above the images. | ||
|
|
||
| Used in messengers: WhatsApp, Telegram. | ||
|
|
||
| If we display the message text above the images, it will be the main body of the | ||
| message, and the attached images will provide additional context. | ||
|
|
||
| In this mode, users sometimes want to add individual captions or comments to | ||
| specific images in a gallery, which is not possible today. | ||
|
|
||
| 3. Text with inline images | ||
|
|
||
| Used in messengers such as Microsoft Teams and Skype. | ||
|
|
||
| This approach covers the previous approaches and allows placing text anywhere: | ||
| before images, after images, or between images. | ||
|
|
||
| It also permits grouping images into sub-galleries inside a single message. | ||
|
|
||
| Therefore, this approach appears to be the most flexible and user-friendly. | ||
|
|
||
| --- | ||
|
|
||
| There were already several MSCs related to the image galleries and multiple | ||
| media attachments: | ||
|
|
||
| - [MSC2881: Message | ||
| Attachments](https://github.com/matrix-org/matrix-spec-proposals/pull/2881) | ||
|
|
||
| - [MSC3382: Inline message | ||
| Attachments](https://github.com/matrix-org/matrix-spec-proposals/pull/3382) | ||
|
|
||
| - [MSC4274: Inline media galleries via | ||
| msgtypes](https://github.com/matrix-org/matrix-spec-proposals/pull/4274) | ||
|
|
||
| But they cover only one type of galleries, and require changes on the server | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that's not correct. #4274 is purely client-side. |
||
| side. | ||
|
|
||
| This MSC covers all gallery times and requires only changes on the client side. | ||
|
|
||
| ## Security considerations | ||
|
|
||
| None identified. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implementation requirements: