Skip to content

Conversation

@Lymkwi
Copy link

@Lymkwi Lymkwi commented Apr 30, 2024

Starting with Client-Server API v1.10 [0], the body field in messages of type m.image, m.audio, m.video and m.file can be used as the caption of the attachment. This is fact the way that Nheko rends captions on images, for example.

This commit introduces a field in the UploadHandles awaiting upload on the timeline's InputBar which holds a caption taken from the input text area. The decision is as follows:

  • If text bar is empty or full of blanks, send all media with no caption
  • If the text is an incomplete command, fail
  • If there are no pending uploads, proceed as done previously (if there is no command recognized send the text, or try and execute the command and if it fails send the text)
  • If there are pending uploads, only accept uploads if nothing resembling a command name is in the text area. That text becomes the caption for all pending media. Otherwise, try and execute the command, and, if it fails, send it as text.

While this workflow for captioning so far is a bit jank, it is the least effort implementation.

Links:
[0]: https://spec.matrix.org/v1.10/client-server-api/#mimage


Do let me know if i missed anything important in the workflow of InputBar , i tried to get a feeling for what methods had to be called in what order to process the input text but there's always a chance i missed something important.

@Lymkwi Lymkwi force-pushed the feature/media-captioning branch from ffee5a4 to a291925 Compare May 1, 2024 10:56
Starting with Client-Server API v1.10 [0], the `body` field in messages of type `m.image`,
`m.audio`, `m.video` and `m.file` can be used as the caption of the attachment. This is fact the way
that Nheko rends captions on images, for example.

This commit introduces a field in the `UploadHandle`s awaiting upload on the timeline's `InputBar`
which holds a caption taken from the input text area. The decision is as follows:
 - If text bar is empty or full of blanks, send all media with no caption
 - If the text is an incomplete command, fail
 - If there are no pending uploads, proceed as done previously (if there is no command recognized
   send the text, or try and execute the command and if it fails send the text)
 - If there are pending uploads, only accept uploads if nothing resembling a command name is in the
   text area. That text becomes the caption for all pending media. Otherwise, try and execute the
   command, and, if it fails, send it as text.

While this workflow for captioning so far is a bit jank, it is the least effort implementation.

Links:
[0]: https://spec.matrix.org/v1.10/client-server-api/#mimage

Signed-off-by: lymkwi <[email protected]>
@Lymkwi Lymkwi force-pushed the feature/media-captioning branch from a291925 to 50cdcc0 Compare May 1, 2024 11:03
@q234rty
Copy link
Contributor

q234rty commented May 3, 2024

Note that nheko does not really support rendering long captions on images i.e. it resorts to ellipses for captions that does not fit the image, which is IMO a blocker for this PR.

@Lymkwi
Copy link
Author

Lymkwi commented May 3, 2024

Note that nheko does not really support rendering long captions on images i.e. it resorts to ellipses for captions that does not fit the image, which is IMO a blocker for this PR.

My impression as i was implementing it was that the caption display was really meant to show a filename, which is what the body field was used for prior to spec v1.10

Could a solution to that be having a tooltip displaying the caption? That's the only way i can think of for adding the caption without breaking the way the UI renders at the moment

@q234rty
Copy link
Contributor

q234rty commented May 4, 2024

Could a solution to that be having a tooltip displaying the caption? That's the only way i can think of for adding the caption without breaking the way the UI renders at the moment

Well, I would say just display the caption underneath the image...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants