Attaching images and other files to messages

User story:

Currently it’s possible to attach images to messages. The frontend restricts these to be square, and they are reduced in size before upload.

If would be useful if people could attach images such that they maintain their original aspect ratio and size. Additionally, being able to add other kinds of files as attachment has been requested multiple times.
I looked at what telegram and whatsapp do in this regard.

Don't force square images · Issue #2545 · karrot-dev/karrot-frontend · GitHub is an existing issue dealing with some of this and https://github.com/karrot-dev/karrot-backend/pull/1256 is my current work-in-progress.

Complexity:

Backend has been quite straightforward to build, after some time spent pondering how it could be implemented nicely.

Frontend is most fiddly, so will explore some more of that in subsequent messages in this thread.

Outcomes (or what needs to be done to move forward):

  • need to collect the examples of UI/UX from telegram/whatsapp
  • come up with a concept for karrot based on this
  • implement the frontend!
  • do anything more needed for the backend

Telegram desktop pops open a message compose dialog when you attach a file, that allows you to add a “caption” (which is sort of instead of the message), add more files, and manipulate the file. If you select an image, it’ll include an option to “compress the image”, which downsizes it and makes is show inline as a gallery… otherwise it adds it as a file.

Telegram mobile makes you choose image (“gallery”) or file initially (and a range of other options), and has a multi-select “bottom sheet” style dialog.

WhatsApp desktop has a “fab” style menu that pops up from the attachment paperclip button with images, files, and other options.

Selecting an image puts you into a gallery-creation dialog:

Selecting a file puts you in something that looks very similar! Can add multiple files, and it gives you a preview of each of them:

(I think the main difference with files and images, is that it will resize images, but not files)

WhatsApp mobile has a bottom-sheet kind of dialog for the attachment type,

Then a gallery mode for multiple images:

For documents, you can select multiple ones:

But they just go into the chat as multiple individual “file” messages:

I had a look at Slack desktop too, which is actually maybe a more similar model to karrot…

You can attach files or images… and they show up in a similar way (they upload immediately):

Images can be edited a bit (no cropping etc though):

If you include any number of non images the attachments are rendered like this:

Whereas if you have only images, it shows them like a gallery:

And for good measure, here’s how Karrot works right now:

An “image” button to add images (only 1 at a time):

But can do that multiple times, and they show up inline below the message:

If any design-orientated people here, e.g. @bruno or @hwojcik want to try out some sketches for a new conversation compose (the bit where you write a message), then I would welcome that! … I’m thinking to make it a bit like the slack one…

  • something to differentiate the WHOLE conversation compose thing, slack has a thin border…
  • add buttons along the bottom of that (rather than the right side of the input field)
  • attachment button, and message formatting tips on left, preview and submit buttons on the right
  • allow to add files, so they show up a bit like the images do right now
  • allow to add multiple files/images at once
  • don’t crop images (even if the preview shows as square, upload full image)
  • if adding any image editing, make that in a dialog that opens when you click the image

One unresolved thing is files vs images

  • many platforms separate images that will show inline as a gallery, vs files as attachments (that might include images)
  • when adding an “image” specifically, platforms often downsize them, reduces upload size
  • when adding a “file” (image or other) they will upload the full size

I’ve actually made two variations of the backend:

  1. treat everything as “attachments”, which might be an image or file
  2. have both “images” and “attachments” independently, which makes the code somewhat easier for some cases

The slack-like approach does not distinguish though, whereas telegram/whatsapp do.

A little summary of what we discussed today:

-we go for the Slack model of attaching images and files and showing a preview below the message.

  • preserve distinction of choosing between images and attachments, and maybe add Camera option

  • plus button to attach something

    • placed below the field for writing the message (on the left?), and shrink the help for markdown to a help icon only (?)
    • when clicking comes the choice option as “fab” style menu on desktop, and on mobile maybe a bottom sheet dialog
  • keep send button on the same place…

  • preview for images keep the correct aspect ratio, and have a a remove button on it only

    • bonus: open the image for basic editing (rotate, zooming, and more stuff in the future)
  • when attaching file file: show preview with the name and size. Upload the whole thing. If an image is attached as a file, there’s no image preview and it’s uploaded full size

  • Image attachments will be compressed, maybe a download icon on the corner of the image when viewing the image after posted

  • when composing a message with attachments, add a gap and/or a frame to distinguish it from previous messages on the wall

    • how to solve that on a chat (activity or application chat for ex.)