I’ve seen a lot of wishes in various comments and feature requests for Lemmy to support image galleries (e.g. similar to Reddit posts with multiple images you can swipe through).

My first thought was to just detect multiple images in the post body and render those (plus the thumbnail) as a gallery instead of just the thumbnail image. That’s absolutely doable, but perhaps there’s a better way?

My second thought, which is what I now prefer, was to make a custom markdown container for an image gallery (the same way the spoiler tag is implemented).

e.g.

:::gallery Gallery Title
![Image 1 Alt Text](https://example.com/image1.jpg "Caption for Image 1")
![Image 2 Alt Text](https://example.com/image2.jpg "Caption for Image 2")
![Image 3 Alt Text](https://example.com/image3.jpg "Caption for Image 3")
:::

It would then render that as an image gallery that can be swiped through.

Pros

  • Easy to implement in most markdown libraries that support custom containers (markdown-it, marked-js, etc)
  • Easy syntax for users
  • Allows explicitly creating a gallery instead of relying on implicit behavior (e.g. detecting / rendering multiple post body images as a gallery)

Cons

  • The custom markdown container would need to be implemented by clients (preferably more than just one or two)
  • It wouldn’t work in Lemmy-UI (hey, they should have to adopt one of our features for a change)
  • The “title” component of the markdown image syntax would be interpreted by some clients as the code for a custom emoji, so that may need to be omitted if we want this to fail mostly-gracefully in less capable apps (cough Lemmy UI cough).

Thoughts? Other suggestions?

  • Admiral Patrick@dubvee.orgOP
    link
    fedilink
    English
    arrow-up
    5
    ·
    edit-2
    18 days ago

    Assuming the custom container for galleries doesn’t take off, my backup plan is to use my original idea of detecting multiple images in the post bodies and populating a gallery. To make that behavior explicit, I would probably only trigger that behavior if the post title has a gallery tag/flair (eg. Check out my vaction photos [Gallery]).

    Either way, I’d like to get feedback from other app developers to see if they’d be interested in supporting similar behavior and standardizing it.