-
Notifications
You must be signed in to change notification settings - Fork 434
MSC4274: Inline media galleries via msgtypes #4274
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| # MSC4274: Inline media galleries via msgtypes | ||
|
|
||
| Matrix allows sharing individual media files such as images or videos via | ||
| dedicated [`m.room.message` msgtypes]. This is, however, not practical for | ||
| sharing larger collections of files. For one thing, there is no mechanism to set | ||
| a joint caption for several media files. For another, there is no way to inform | ||
| other clients that a set of pictures belongs together and should be grouped | ||
| accordingly in the timeline. These shortcomings call for a built-in media | ||
| gallery feature as it is widely known from other messaging apps. | ||
|
|
||
| This proposal defines a compact and pragmatic variant of sharing media galleries | ||
| in a single event. | ||
|
|
||
| ## Proposal | ||
|
|
||
| A new `msgtype` of `m.gallery` is introduced with the following properties in | ||
|
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. If we are taking in the scope not only images, but also files ( From my point of view, the best term for this feature is "attachments", because actually on the technical side we have a regular And the term "gallery" is related more to the displaying style, not to the message type, because a message with 5 attached So, naming this not as a "gallery" but using a more general term, will extend the scope of such message type, and will allow, in the future, to put into What do you think about this idea? |
||
| `content`: | ||
|
|
||
| - `body` (string): The caption of the gallery. | ||
| - `format` (string): The format used in `formatted_body`. Currently only | ||
| `org.matrix.custom.html` is supported. | ||
| - `formatted_body` (string): The formatted version of the body. Required if | ||
| `format` is specified. | ||
| - `itemtypes` (array): Ordered array of metadata for each item in the gallery. | ||
|
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. Why is this called
Contributor
Author
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. Hm, I think I landed on this because |
||
|
|
||
| The objects in the `itemtypes` array have the same schema as the `content` of | ||
| the msgtypes `m.image`, `m.video`, `m.audio` and `m.file`. Rather than | ||
| `msgtype`, they use `itemtype` though. | ||
|
|
||
| ``` json5 | ||
| { | ||
| "type": "m.room.message", | ||
| "content": { | ||
| "msgtype": "m.gallery", | ||
| "body": "Checkout my photos from [FOSDEM 2025](https://fosdem.org/2025/)", | ||
| "format": "org.matrix.custom.html", | ||
| "formatted_body": "Checkout my photos from <a href=\"https://fosdem.org/2025/\">FOSDEM 2025</a>", | ||
| "itemtypes": [{ | ||
| "itemtype": "m.image", | ||
| "body": "filename.jpg", | ||
| "info": { | ||
| "h": 398, | ||
| "mimetype": "image/jpeg", | ||
| "size": 31037, | ||
| "w": 394 | ||
| }, | ||
| "url": "mxc://example.org/JWEIFJgwEIhweiWJE", | ||
| ... | ||
| }, ...] | ||
| }, | ||
| ... | ||
| } | ||
| ``` | ||
|
|
||
| ## Potential issues | ||
|
|
||
| The size of galleries under this proposal is limited by the event size limit | ||
| (65,536 bytes). An encrypted gallery event with a single image, including | ||
| thumbnail, and no caption measures about 2,000 bytes. Each additional image adds | ||
| roughly another 1,000 bytes. Therefore galleries would be capped to about 60 | ||
| images. While this is a limitation, the amount seems practical for most use | ||
| cases. | ||
|
|
||
| Additionally, this proposal doesn't prescribe a fallback mechanism for clients | ||
| that don't support `m.gallery` msgtypes. Clients that care about backwards | ||
| compatibility could encode media links or a generic fallback text into `body` or | ||
| `formatted_body`, respectively. It is unclear, however, if a fallback is | ||
| actually desirable or not because unwrapping 60 images into somebody else's | ||
| timeline might be considered inappropriate if not spammy. | ||
|
|
||
| ## Alternatives | ||
|
|
||
| This proposal is similar to the seemingly abandoned [MSC3382]. The latter | ||
| conflates galleries into `m.text` (or even arbitrary) msgtypes and reuses | ||
| `msgtype` inside the items which creates a circular dependency. These issues are | ||
| solved in the present proposal. | ||
|
|
||
| Rather than adding a new `msgtype`, galleries could be expressed via extensible | ||
| events by reusing parts of [MSC1767] and related proposals. This would only take | ||
| effect in a future room version, however, and can be covered in a separate MSC. | ||
|
|
||
| Another alternative is to define galleries as chains of related events as in | ||
| [MSC2881]. Compared to the inline approach taken in this proposal, this has | ||
| better fallback support, is more flexible and less prone to event size limits. | ||
| At the same time, it is significantly more complex to implement in terms of | ||
| replies, edits, redactions, forwarding, etc. | ||
|
|
||
| Finally, rather than defining galleries on the sender's side, receiving clients | ||
| could opportunistically group consecutive images in the timeline into galleries. | ||
| This might need specific rules such as grouping by sender or time windowing. | ||
| Different clients might prefer very different display rules, however. Therefore, | ||
|
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 we should clarify here the displaying rules: where the "body" text should be displayed - above the attached items or below them, or maybe add a field that holds the display style. Because this is crucial from the user point of view:
Both variants of rendering are possible and available in different messengers, but they bear completely different meanings of the message.
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, personally, am a fan of the Slack style, not Telegram style ;) Just imagine a message: Variant 2: The order of things in variant 1 looks more correct, right?
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. Actually, these are two totally different things from the logical point of view:
And if we keep the text named as "body", we should put it above. Or, rename to "caption" then. Or, maybe even keep both ones ;) with recommendations what to render where. |
||
| it seems more practical that the spec annotates galleries clearly while leaving | ||
| their UI treatment to clients themselves. | ||
|
|
||
| ## Security considerations | ||
|
|
||
| None. | ||
|
|
||
| ## Unstable prefix | ||
|
|
||
| Until this proposal is accepted into the spec, implementations SHOULD refer to | ||
| `m.gallery` as `dm.filament.gallery`. | ||
|
|
||
| ## Dependencies | ||
|
|
||
| None. | ||
|
|
||
| [`m.room.message` msgtypes]: https://spec.matrix.org/v1.13/client-server-api/#mroommessage-msgtypes | ||
| [MSC3382]: https://github.com/matrix-org/matrix-spec-proposals/pull/3382 | ||
| [MSC1767]: https://github.com/matrix-org/matrix-spec-proposals/pull/1767 | ||
| [MSC2881]: https://github.com/matrix-org/matrix-spec-proposals/pull/2881 | ||
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:
Uh oh!
There was an error while loading. Please reload this page.
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.
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.