🖼️ Topic Gallery

:information_source: Summary Add a gallery view for each topic
:eyeglasses: Preview Click to see a gallery example
:hammer_and_wrench: Repository Link https://github.com/Canapin/discourse-topic-gallery
:open_book: Install Guide How to install plugins in Discourse

Description

Topic Gallery displays all images from a discussion on a dedicated page.

Use cases

Ideal for image-focused communities and/or categories in which users post many pictures.
It allows for a full picture experience without the regular topic interface and other contents getting in the way.

Mobile view:

You can try it here. This is primarily a test instance, so the availability is not guaranteed.

Features

Main features

  • Infinite swiping! [1]

  • User and date filters

  • Starts gallery from a given post

  • Group-specific access

  • Category-based exclusions

  • Link to the source post below the currently open image, so you’re never lost:
    Gallery Topic source post link

  • Shows grouped pictures (belonging to the same post) on mouse over:
    Topic Gallery grouped pictures

Navigation from a topic to a gallery

Several buttons are available to navigate from a Topic to a Gallery:

  • Below the timeline:

  • At the end of a topic:
    Topic Gallery topic button

  • On each post (can be disabled in the settings):
    Topic Gallery post button
    :information_source: If we open the gallery from a post, the gallery is filtered and only shows images starting from this post. You can cancel this filter with a single click:
    image

Gallery URLs

The gallery URL syntax is the same as a regular topic, but /t/ is replaced with /gallery/:

https://canapin.discourse.diy/t/share-your-pictures/10
:backhand_index_pointing_down:
https://canapin.discourse.diy/gallery/share-your-pictures/10

There’s also a public JSON endpoint:
https://canapin.discourse.diy/gallery/share-your-pictures/10.json

Security & queries

  • Feature access is restricted to allowed groups and in allowed categories.
  • Galleries are restricted to users with access to their source topic.

Uploads queries exclude:

  • The order of pictures from a post is preserved
  • Non-user-uploaded images
  • Non-post references (custom emojis, avatars, etc.)
  • Uploads from posts that the current user has no access to, meaning:
    • Whispers (if the current user can’t see whispers)
    • Hidden posts
    • Deleted posts
    • Ignored users’ posts

Gallery Behavior

  • Hotlinked images are not shown.

  • Small images are not shown (minimum resolution can be changed in settings).

  • Duplicate images are shown once.

  • Images in quotes are shown.

Settings

Name Type Default Description
topic_gallery_enabled boolean true Enable the topic gallery plugin.
topic_gallery_allowed_groups group_list admins Groups that are allowed to access the topic gallery.
topic_gallery_minimum_image_size integer (0–1000) 64 Minimum width and height (in pixels) for images to appear in the gallery. Images smaller than this in either dimension are excluded.
topic_gallery_excluded_categories category_list "" Categories where the topic gallery is disabled. Topics in these categories will not show gallery buttons or the gallery page.
topic_gallery_post_menu_button boolean true Show a gallery button inside each post.

:information_source: By default, the plugin is enabled for admins only. Visit settings to enable other groups.


  1. Reaching the end of the first batch of images automatically loads and appends the next batch. ↩︎

13 Likes

I finally released this plugin :slight_smile:

You can see a preview here: Gallery - Share your pictures! - Canapin

2 Likes

This is such a cool idea and implementation.
Will try this later but is there a way to add image description that would show on the image popup below image?

1 Like

I think you can use alt text:

![Some alt text here](upload://...)

You can also click on the above image to see the alt text.

2 Likes

Ah, there’s an oversight from me. This plugin’s photoswipe configuration seems to show the original filename instead of the custom title. I’ll fix this :slight_smile:

2 Likes

@Canapin Why not use the built-in Discourse lightbox()?

Apparently, while I can use the built-in lightbox (that’s I was doing in the first versions of this plugin), I can’t configure and tweak it for my needs. Notably, I couldn’t have it interact with my methods for the infinite loading/swiping, so I had to ship my own.

1 Like

I can’t fix this, unfortunately. Image titles are written in the posts’ content and aren’t stored in any table.

For performance reason, my queries don’t return the posts’ content, so I can’t parse it to retrieve the titles.

I guess I’ll leave the filenames then. Even tho this information is rarely valuable… :thinking:
Non-modified filenames most of the time just reveal where the image comes from and nothing more.

For example in my test instance:

  • image.png → “image” filenames are images pasted directly in the composer

  • Gemini_Generated_Image_8h4wt58h4wt58h4w.jpg → Guess

  • ComfyUI-ExtraMD-Large_315126945425344_00000.jpg → Local AI image generator

  • the-tattooer-is-totally-right-v0-s2f8spm3l-D5908.jpg → Probably saved from a website

  • cropped-android-chrome-512x512-1-32x32.png → Smartphone screenshot

Etc.

Should I consider it as a sensitive information? Image names are used by default for titles when we upload them on Discourse. If we edit the titles, the original information is unavailable for users. Yet, this plugin discloses it.

Edit: Yeah, I should probably not display the original filename. :thinking:

Re-edit: Fixed. :slight_smile:

1 Like