This module provides a field formatter for displaying media reference fields as interactive image galleries using the lightGallery JavaScript library. It supports mixed content like images and videos, offers reusable gallery profiles for easy configuration, and includes touch gestures, zoom, fullscreen, and thumbnail options without requiring external libraries.
Synopsis
A field formatter for Media reference fields using the lightGallery JavaScript library. Mix images, YouTube and Vimeo videos, and PDF Documents in one gallery, with very little configuration.
For humans
So, one of the main ideas of this module is to simplify the installation process.
A lot of my clients complain that to install a module on Drupal, you need to graduate from another university, because you try to install a module, and together with it you need to pull in one, two, three other libraries. You need some specific knowledge, and so on.
Of course, there are several LightGallery modules on Drupal, but how is this one different?
It is simple. You install it, enable it, and it already works.
You do not need to:
- go and download extra libraries
- ask developers or programmers to set it up for you
- install it and download the right library
- read the documentation, and so on
So, you install this module and enable it. If you need a demo, enable the demo version of this module, look at how it works, turn the demo off.
That's it, and it works.
Thanks!
Screenshots
Tutorial
Features
- Profile-based configuration — create reusable gallery profiles with different settings
- Profile cloning — copy an existing profile from the profile list
- Live preview — see the gallery while you edit a profile. Enable the Preview submodule.
- Demo — enable the Demo submodule to see a working gallery, then disable it when you are finished
- Bundled lightGallery — includes lightGallery 3.0.0, so no separate JavaScript library is required
- PDF Documents — show standard PDF media in the same gallery, with one shared thumbnail chosen in Media Library
- Remote Video Support — automatic YouTube and Vimeo thumbnail extraction
- Touch and Swipe — full mobile support with gestures
- Modern JavaScript — built with React 19.3.0, with no jQuery dependency
- Rich Controls — zoom, fullscreen, thumbnails, download, and keyboard navigation
Why LightGallery Formatter?
Unlike drupal/lightgallery, which requires configuring each field separately, this module utilizes reusable profiles. Create as many profiles as you need and switch between them instantly—configure once, use everywhere.
Zero-Dependency: There is no need to mess around with third-party libraries or manual Composer paths. Everything is built directly into the module. To see the full potential of these features, we strongly encourage you to install the "Lightgallery Formatter Demo" sub-module included in the package.
Key Advantages
- Native Media Support — Fully supports mixed content in a single gallery: images, YouTube videos, Vimeo videos, and standard PDF Documents.
- Zero External Libraries — Works out of the box with Drupal core Media. lightGallery 3.0.0 and React 19.3.0 are included. No manual JavaScript downloads, extra libraries, or complex Composer steps.
- No JSON required — All settings via UI checkboxes and dropdowns. No need to learn the LightGallery API.
- Profile-based settings — Change one profile, update all galleries instantly (thanks to @bbu23 and @nk_).
- 30+ transitions — Slide, Fade, Zoom, Lollipop, Rotate, and more — all selectable from a dropdown.
- Config export — Profiles sync between environments via standard Drupal configuration.
- Live preview — Generate a live preview directly within the profile settings.
Also Supports
- Keyboard controls (Esc key, arrow keys, mouse wheel navigation)
- Touch gestures (swipe, drag)
- UI customization (close icon, maximize, counter, download button)
- Auto-hide controls with configurable delay
- YouTube and Vimeo thumbnail extraction
- Live preview when editing profiles
Similar Projects
- Swiper formatter — mobile slider library
- Colorbox — classic lightbox, jQuery-based
- PhotoSwipe — gesture-focused gallery
- GLightbox — modern lightbox with video
- Lightgallery — one of the well-known older integrations of lightGallery into Drupal. Installation needs extra work in
composer.jsonand is not straightforward.
Submodules
- LightGallery Formatter Demo — demo content for testing
- LightGallery Formatter Preview — live preview when configuring profiles
Credits
Many, many thanks to Sachin Neravath for lightGallery. This module is possible because of his work. The library is licensed under GPLv3.
Installation
The JavaScript is already in the package. Install the module with Composer:
composer require drupal/lightgallery_formatterEnable the module via Drush:
drush en lightgallery_formatterOptional Submodules:
lightgallery_formatter_preview: Adds a live preview tab to the profile configuration.lightgallery_formatter_demo: Creates a content type and demo nodes for testing.
Enable them if needed:
drush en lightgallery_formatter_preview lightgallery_formatter_demoFor Developers
The project uses ddev-drupal-contrib for local development.
Quick Start
git clone [email protected]:project/lightgallery_formatter.git cd lightgallery_formatter ddev start ddev lgf:init
This installs Drupal with demo_umami profile, enables the module with demo content, and provides admin login.
Useful Commands
ddev lgf:init— full reset and fresh installddev phpcs— check coding standardsddev phpcbf— auto-fix coding violationsddev phpstan— run static analysisddev phpunit— run tests
Architecture
- Drupal renders a static gallery first. React then mounts lightGallery 3 on that markup.
- Gallery behavior is stored in reusable profiles. Each LightGallery feature is its own plugin.
Ask your assistant about Lightgallery Formatter
Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works
Depends on
Dependencies of the latest stable release
- media Drupal core
- media_library Drupal core
Required by
Tracked projects that depend on this one
No tracked projects depend on this one yet.