Breakdance4fun Logo

Create a Gallery Lightbox with Thumbnails from a single image

Breakdance uses the LightGallery JS library for its lightbox features, so all dependencies are already included.

The following code shows how to open a Lightbox gallery with thumbnails when you click on a single image.

Oxygen Builder and Breakdance Builder illustrated characters showcasing dance and web design talents in urban streetwear, promoting creativity and web development skills.

Step 1

Use the Supa Code Block element from the Assets4Breakdance plugin (it's free, don't worry).

Add your image as a child of that element:

Supacodeblock image

Step 2

In the Options, select LightGallery as a dependency, so we know it's going to load the library is it's not already loaded.

Supacodeblock lightgallery

Step 3

Paste the JavaScript code and CSS code into the Supa Code Block.

Then replace the gallery URL with own image URLs.

// Define your gallery items
const galleryItems = [
{
src: '/wp-content/uploads/2025/10/cool-image.png',
thumb: '/wp-content/uploads/2025/10/cool-image-150x150.png',
subHtml: '<h4>my cool image</h4>',
alt: 'my cool image'
},
{
src: '/wp-content/uploads/2025/10/cool-photo.png',
thumb: '/wp-content/uploads/2025/10/cool-photo-150x150.png',
subHtml: '<h4>my cool photo</h4>',
alt: 'my cool photo'
},
{
src: '/wp-content/uploads/2025/10/cool-illustration.png',
thumb: '/wp-content/uploads/2025/10/cool-illustration-150x150.png',
subHtml: '<h4>my cool illustration</h4>',
alt: 'my cool illustration'
}
];

document.querySelector('%%SELECTOR%% img').addEventListener('click', function (event) {
const dynamicGallery = lightGallery(document.body, {
dynamic: true,
dynamicEl: galleryItems,
thumbnail: true,
plugins: [lgThumbnail, lgZoom],
animateThumb: true,
allowMediaOverlap: true,
controls: true,
download: false, // enable download if needed
});
dynamicGallery.openGallery();
});
%%SELECTOR%% {
cursor: pointer
}

.lg-media-overlap .lg-sub-html {
background-image: unset
}

.lg-sub-html h4 {
display: inline;
background-color: var(--bde-brand-primary-color);
padding: 5px 10px;
border-radius: 8px;
color: black
}

.lg-outer .lg-thumb-item.active,
.lg-outer .lg-thumb-item:hover {
border-color: var(--bde-brand-primary-color)
}

Supa Tip

Since we are using the Supa Code Block, we can create a more sementic structure, using the figure and figcaption tags. Don't forget to select the figcaption tag for your text element (in the Advanced panel).

 

Supacodeblock figureSupacodeblock sementic image
Breakdance, hip-hop dance, sneakers, street dance, urban dance, breakdancing illustration, dance culture, streetwear style, youth fashion, breakdance choreography.
This is my cool caption