|
| 1 | +# MSC2448: Using BlurHash in Media Events |
| 2 | + |
| 3 | +[BlurHash](https://blurha.sh) is a compact representation of a placeholder |
| 4 | +for an image (or the frame of a video). Currently in Matrix, clients must |
| 5 | +display a placeholder image in the message timeline while a piece of media is |
| 6 | +loading. Some clients, such as Riot, simply display an empty space. |
| 7 | + |
| 8 | +While thumbnails exist to combat this to some degree, they still need to be |
| 9 | +downloaded from a homeserver, which is not instantaneous. |
| 10 | + |
| 11 | +Instead, a blurhash can be sent inside the `m.room.message` event, which upon |
| 12 | +receipt other clients can render for a pretty preview while the actual |
| 13 | +thumbnail downloads. |
| 14 | + |
| 15 | +## Proposal |
| 16 | + |
| 17 | +A new field is added in `m.room.message`'s `content` called `blurhash`. It |
| 18 | +is a BlurHash of the original piece of media. Clients could then render this |
| 19 | +using [one of the available BlurHash |
| 20 | +implementations](https://github.com/woltapp/blurhash). |
| 21 | + |
| 22 | +This would be displayed while the thumbnail of the media is loaded in parallel. |
| 23 | + |
| 24 | +This is beneficial as it's an extremely efficient way to give someone a quick |
| 25 | +idea of what a piece of media contains before any requests are made to a |
| 26 | +media repository. |
| 27 | + |
| 28 | +To be clear: This does not replace thumbnails - it will be shown before they |
| 29 | +are downloaded. |
| 30 | + |
| 31 | +## Visualisation |
| 32 | + |
| 33 | +Viewing an image message that is loading: |
| 34 | + |
| 35 | + |
| 36 | + |
| 37 | +Once the image loads: |
| 38 | + |
| 39 | + |
| 40 | + |
| 41 | +For reference, the current state of things in Riot is: |
| 42 | + |
| 43 | + |
| 44 | + |
| 45 | +## Alternatives |
| 46 | + |
| 47 | +We could include a base64 thumbnail of the image in the event, but blurhash |
| 48 | +produces much more efficient textual representations. |
| 49 | + |
| 50 | +## Backwards compatibility |
| 51 | + |
| 52 | +Older clients would ignore the new `blurhash` parameter. |
| 53 | + |
| 54 | +Newer clients would only show it if it exists. |
0 commit comments