Display images in a lightbox
Description
Provide the ability to open images of a page in a lightbox (gallery view) with information about the displayed image (e.g. captions, author), possible actions (e.g. zoom, fullscreen, download) and the possibility to cycle through all of them.
Requirements
Key requirements:
- ability to click on the images displayed inside the page content for displaying the lightbox, from browser or mobile
- ability to apply some constraints for the selected images
- display information like caption, author, date of creation
- have option to download the currently displayed image
- have option for fullscreen mode
- give admins the possibilty to disable the feature
Implementation analysis
JS library investigation
The following table presents information about the investigated libraries.
| Name | License | Contributors | Last Release | Releases in last 2 years | Last commit | Active committers in last 6 months | Start year | Notes | Lightbox display customizations and code style |
|---|---|---|---|---|---|---|---|---|---|
| SimpleLightbox (Demos) | MIT | -> Github (not relevant since there are commits done without authentication that don't appear in this graph) | Nov 2021 | 24 | Nov 2021 | ~1 (almost 20 commits) | 2015 |
|
|
| GLightbox (Demos) | MIT | -> Github | Aug 2021 | 12 | Oct 2021 | 1 (there are also a small number of commits done by the community) | 2013 |
|
|
| Photoswipe (Demos) | MIT | -> Github | Jan 2019 | 0 | master: Apr 2021 v5-beta: Oct 2021 | master: 0 v5-beta: 1 | 2011 |
|
|
| Gallery (Demos) | MIT | -> Github | Sept 2021 | 15 | Sept 2021 | 1 | 2013 |
|
|
| ImageLightBox (Demos) | MIT | -> Github | Jun 2020 | 1 | Nov 2021 | 1 | 2014 |
|
|
Inline (embedded) gallery
The possibility to have an inline gallery, similar to what the Gallery Macro offers, is an important feature as well. Since these two are similar as functionalities, it is desired, even if not mandatory, to use the same library for both of them. For this I tried the functionality for 3 of the libraries above:
1. Gallery
As seen on the demo page, there is a carousel view. It does not have by default the possibility to open from it the lightbox, but this option can be added using a button for opening a new gallery in lightbox mode.
2. GLightbox
It is not a given feature, but I managed to modify it in order to see if it can be done. What I modified:
- a problem is that the library does not offer the possibility to append the gallery to a specific parent element (it uses the document), so I moved it manually
- some css rules need to be changed to have position:
relative
- you cannot have more than one glightbox opened, and it causes problems if you need to go from embedded to fullscreen mode, but I think it can me managed
3. Photoswipe
As presented on this comment https://github.com/dimsemenov/PhotoSwipe/issues/1749#issuecomment-860647842 , under Inline section, there is an experimental modal option for the v4 version, but it is no longer available in v5.
Lavinia Vitel