Skip to content
This repository was archived by the owner on Dec 7, 2024. It is now read-only.

Commit 90817f3

Browse files
committed
Developer documentation
The lint rules don't currently exist, but would apply to `mxcUrlToHttp` and `getHttpUriForMxc`
1 parent a9a4bd5 commit 90817f3

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

docs/media-handling.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Media handling
2+
3+
Surely media should be as easy as just putting a URL into an `img` and calling it good, right?
4+
Not quite. Matrix uses something called a Matrix Content URI (better known as MXC URI) to identify
5+
content, which is then converted to a regular HTTPS URL on the homeserver. However, sometimes that
6+
URL can change depending on deployment considerations.
7+
8+
The react-sdk features a [customisation endpoint](https://github.com/vector-im/element-web/blob/develop/docs/customisations.md)
9+
for media handling where all conversions from MXC URI to HTTPS URL happen. This is to ensure that
10+
those obscure deployments can route all their media to the right place.
11+
12+
For development, there are currently two functions available: `mediaFromMxc` and `mediaFromContent`.
13+
The `mediaFromMxc` function should be self-explanatory. `mediaFromContent` takes an event content as
14+
a parameter and will automatically parse out the source media and thumbnail. Both functions return
15+
a `Media` object with a number of options on it, such as getting various common HTTPS URLs for the
16+
media.
17+
18+
**It is extremely important that all media calls are put through this customisation endpoint.** So
19+
much so it's a lint rule to avoid accidental use of the wrong functions.

0 commit comments

Comments
 (0)