Lightbox Gallery Component Written in Vanilla JS | ensemble.Lightbox.js

ensemble.Lightbox.js class from loltgt and this plugin are lightbox gallery built using plain JavaScript.

responsive grid gallery with lightbox popup and tag filter, responsive lightbox image gallery jquery, lightbox image gallery with thumbnails, javascript image gallery with thumbnails

Features:

  • Supports any content: Image, text, iframe, video, pdf, etc.
  • Supports modern image formats: WebP and Avif.
  • Supports dynamic content creation.

How to make use of it:

1. To get started, including Ensemble Lightbox’s JavaScript and Stylesheet on the web page.

<link rel=”stylesheet” href=”dist/css/ensemble-lightbox.min.css” />
<script src=”dist/js/ensemble-lightbox.min.js”></script>

2. Create a lightbox gallery from elements within the doc.

<div class="example">
  <a href="1.jpg">
    <img src="1.jpg" alt="Image Caption" />
  </a>
  <a href="iframe.html" data-caption="iframe">
    <img src="iframe.jpg" alt="Image Caption" />
  </a>
  <a href="pdf.pdf" data-caption="pdf">
    <img src="pdf.jpg" alt="Image Caption" />
  </a>
  // ...
</div>
const lightbox_example = document.querySelectorAll('.example');
for (const lightbox_group of lightbox_example) {
  var lightbox_options = { selector: 'a' };
  if (lightbox_group === lightbox_example[1]) {
    lightbox_options.infinite = false;
  }
  const lightbox = new ensemble.Lightbox(lightbox_group, lightbox_options);
  for (const a of lightbox_group.querySelectorAll('a')) {
    a.addEventListener('click', lightbox.open, true);
  }
}

3. Create a lightbox gallery from parts defined in a JS object.

const lightbox_contents = [
  {
    type: 'element',
    node: (function() { var el = document.createElement('div'); el.innerText = 'Test for a custom element.'; return el; }())
  },
  {
    type: 'video',
    loop: true,
    poster: 'video-test-card.png',
    sources: [
      {
        type: 'video/mp4',
        src: 'video-test-card.mp4'
      },
      {
        type: 'video/webm',
        src: 'video-test-card.webm'
      }
    ]
  },
  {
    type: 'video',
    src: 'https://www.youtube.com/embed/mN0zPOpADL4',
    caption: 'Agent 327: Operation Barbershop\n\nfrom Blender Studio',
    allow: 'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture',
    allowfullscreen: true //TODO FIX
  },
  {
    type: 'video',
    src: 'https://player.vimeo.com/video/325910798',
    caption: 'Spring - Blender Open Movie\n\nfrom Blender Studio',
    allow: 'autoplay; fullscreen; picture-in-picture',
    allowfullscreen: true //TODO FIX
  },
  {
    type: 'audio',
    src: 'https://open.spotify.com/embed/album/54Awn36ryf55PkZyOR4iwQ',
    allowtransparency: true, //TODO FIX
    allow: 'encrypted-media'
  },
  {
    type: 'iframe',
    src: '',
    height: '100%' //TODO FIX
  },
  {
    type: 'audio',
    src: 'audio-test.wav',
    autoplay: true
  }
  // ...
];
const lightbox = new ensemble.Lightbox({ 
      contents: lightbox_contents 
});

4. All default choices.

const lightbox = new ensemble.Lightbox({ 
      className: ['modal', 'modal-lightbox'],
      selector: '',
      contents: null,
      navigation: true,
      captioned: true,
      infinite: true,
      autoDiscover: true,
      autoHide: 'navigation', // "navigation" or "captions"
      overlayed: false,
      checkOrigin: true,
      prev: {
        onclick: this.prev,
        innerText: '\u003C',
        ariaLabel: 'Previous'
      },
      next: {
        onclick: this.next,
        innerText: '\u003E',
        ariaLabel: 'Next'
      },
      onStep: function () {},
      onSlide: function () {},
      onCaption: function () {}
});

Multi-purpose Lightbox Gallery, ensemble Lightbox Plugin/Github, lightbox image gallery html css, bootstrap lightbox multiple images, responsive lightbox gallery


See Demo And Download

Official Website(loltgt): Click Here

This superior jQuery/javascript plugin is developed by loltgt. For extra Advanced Usages, please go to the official website.

Related Posts

Confetti-Falling-Animation-Effect-party

Confetti Falling Animation Effect In JavaScript | party.js

Party.js is a JavaScript library to brighten user site experience with visual effects! Celebrate success with dom confetti! The library is written in TypeScript and compiled into…

Star-Rating-JavaScript

Select Box Based Star Rating JavaScript Library | star-rating.js

star-rating.js is a small JavaScript library to create a customizable and gradually improved star rating control from a regular tick box with numeric values. The ES6 module…

Bootstrap-Show-Notification

Corner Fixed Notifications Alerts With Bootstrap | BS4 Show Notification

Bootstrap Notification is an easy-to-use jQuery plugin that uses the Bootstrap Alerts component to create static, rejectable, and stackable notification popups in the upper right corner of the…

Stackable-Multi-level-Sidebar-Menu

Create Stackable Multi-level Sidebar Menu | HC Off-canvas Nav

Multi-Level Sidebar Slide Menu – HC MobileNav is a jQuery plugin for creating multi-level, mobile-first, totally accessible, off-canvas facet navigation that helps the infinite nesting of submenu…

vue-masonry-gallery

Responsive Masonry Layout with SSR Support for Vue 3 | vue-masonry-wall

Vue masonry wall is a responsive masonry layout component for Vue 3 to deliver a Masonry-style responsive grid layout with SSR and RTL layout support. Features 📱…

bootstrap-5-bs-toaster

A Bootstrap 5 Toast Notification Framework Library | bs-toaster

bs-toaster is simple to instantiate bs-toaster and create multiple toasts effortlessly using native Bootstrap 5! Feature Facts Small and clean Modern browser support. No IE sorry 💥…