Full featured JavaScript image & video gallery. No dependencies

Overview

lightgallery.js

travis bower npm

Full featured JavaScript lightbox gallery. No dependencies.

lightgallery

Important notice

  • lightgallery.js has been merged with lightGallery. That means, v2 of lightgallery.js is https://www.lightgalleryjs.com/. if you have a lightgallery.js license, this is valid for lightGallery as well. But, since version 2.0 you need to pass the license key as a plugin option. If you alredy have a license, please contact me at [email protected] for the license key
  • Completely re-wrote from scratch in typescript
  • Moved all modules to the main repo for better maintainability.
  • Dropped IE 8 and 9 support. Let me know if you still need support for IE 8 and 9. I’ll consider adding a plugin to add support if there is enough demand.
  • Website
  • Docs
  • Demos
Any questions, ideas, suggestions about v2? please start a discussion.

New features

  • Pinch to zoom
  • Virtual slides
  • Swipe to close
  • Zoom from the origin
  • Inline gallery
  • Next-generation image formats support(webp, JPEG XL). etc
  • Better customizability
  • Better performance on mobile devices.
  • Dynamically add, remove slides while the gallery is open
  • Comment interface
  • and much more.

How to upgrade

To make the upgrade seamless, v2 follows the API structure as much as possible. But, few settings are removed and a lot of additional settings are added, the way we use public methods is changed slightly and few events are renamed.

Initialization V2 doesn’t require jQuery as a dependancy.

lightGallery(document.getElementById('lightgallery'), {
  plugins: [lgZoom, lgThumbnail,]
  speed: 500
  ... other settings
});

Plugins To avoid polluting global scope, since v2 plugins has to be passed via settings.

lightGallery(document.getElementById(‘’lightgallery), {
    
plugins: [lgZoom, lgAutoplay, lgComment, lgFullscreen , lgHash, lgPager, lgRotate, lgShare, lgThumbnail, lgVideo]
});
  • Removed in-built support for Dailymotion VK. We Will be adding separate plugins for DailyMotion and VK support
  • Added Wistia support
  • HTML videos - Videos can be passed via data-video attribute instead of passing it via hidden div
data-video='{"source": [{"src":"/videos/video1.mp4", "type":"video/mp4"}], "attributes": {"preload": false, "controls": true}}'
  • Events are renamed - Please take a look at the documentation
  • Few settings are added, removed, or renamed. Rather than listing down all the changes here, I’d recommend going through the current settings that you are using and compare them with the new documentation.



Main features

  • Fully responsive.
  • Modular architecture with built in plugins.
  • Touch support for mobile devices.
  • Mouse drag supports for desktops.
  • Double-click/Double-tap to see actual size of the image.
  • Animated thumbnails.
  • Social media sharing.
  • YouTube, Vimeo, Dailymotion, VK and HTML5 video support.
  • 20+ Hardware-Accelerated CSS3 transitions.
  • Dynamic mode.
  • Full screen support.
  • Supports zoom.
  • Browser history API.
  • Responsive images.
  • HTML iframe support.
  • Multiple instances on one page.
  • Easily customizable via CSS (SCSS) and Settings.
  • Smart image preloading and code optimization.
  • Keyboard Navigation for desktop.
  • Font icon support.
  • Rotate, flip images.
  • Accessibility support.
  • And many more.

Browser support

lightgallery supports all major browsers including IE 9 and above.

Installation

Install with NPM

You can install lightgallery.js using the npm package manager.

npm install lightgallery.js

You can also find lightgallery.js on Yarn and Bower.

Yarn

yarn add lightgallery.js

Bower

bower install lightgallery.js --save

CDN

http://www.jsdelivr.com/projects/lightgallery.js

Download from GitHub

You can also directly download lightgallery from GitHub.

Include CSS and JavaScript files

First of all add lightgallery.css in the <head> of the document.

<head>
    <link rel="stylesheet" href="css/lightgallery.css">
</head>

Then include lightgallery.min.js into your document. If you want to include any lightgallery plugin you can include it after lightgallery.min.js.

<body>
    ...

    <script src="js/lightgallery.min.js"></script>

    <!-- lightgallery plugins -->
    <script src="js/lg-thumbnail.min.js"></script>
    <script src="js/lg-fullscreen.min.js"></script>
</body>

Lightgallery also supports AMD, CommonJS and ES6 modules. When you use AMD make sure that lightgallery.js is loaded before lightgallery modules.

require(['./lightgallery.js'], function() {
    require(["./lg-zoom.js", "./lg-thumbnail.js"], function(){
        lightGallery(document.getElementById('lightgallery'));
    });
});

The markup

lightgallery does not force you to use any kind of markup. You can use whatever markup you want. But i suggest you to use the following markup. Here you can find the detailed examples of different kinds of markup.

<div id="lightgallery">
    <a href="img/img1.jpg">
        <img src="img/thumb1.jpg">
    </a>
    <a href="img/img2.jpg">
        <img src="img/thumb2.jpg">
    </a>
    ...
</div>

Call the plugin

Finally you need to initiate the gallery by adding the following code.

<script>
    lightGallery(document.getElementById('lightgallery'));
</script>

Support lightgallery

If you like lightgallery please support the project by staring the repository or tweet about this project.

Resources

Demos

Built in modules

  1. Thumbnail - GItHub - Docs
  2. Autoplay - GItHub - Docs
  3. Video - GItHub - Docs
  4. Fullscreen - GItHub - Docs
  5. Pager - GItHub - Docs
  6. Zoom - GItHub - Docs
  7. Hash - GItHub - Docs
  8. Share - GItHub - Docs
  9. Rotate - GItHub - Docs

License

Commercial license

If you want to use lightgallery.js to develop commercial sites, themes, projects, and applications, the Commercial license is the appropriate license. With this option, your source code is kept proprietary. Read more about the commercial license

Open source license

If you are creating an open source application under a license compatible with the GNU GPL license v3, you may use this project under the terms of the GPLv3.

Comments
  • Woff2 support for the font

    Woff2 support for the font

    It would be great if the custom font could be provided in woff2 format as well, as it is supported by most browsers and is more efficient than woff (and so should be the preferred format for supporting browsers)

    opened by stof 13
  • lightgallery.js:628 Uncaught Error: Make sure that slide 0 has an image/video src

    lightgallery.js:628 Uncaught Error: Make sure that slide 0 has an image/video src

    <!-- data-src should not be provided when you use html5 videos -->
    <ul id="html5-videos">
      <li data-poster="video-poster1.jpg" data-sub-html="video caption1" data-html="#video1" >
          <img src="img/thumb1.jpg" />
      </li>
      <li data-poster="video-poster2.jpg" data-sub-html="video caption2" data-html="#video2" >
          <img src="img/thumb2.jpg" />
      </li>
    </ul>
    
    opened by starzou 9
  • Plugins with webpack

    Plugins with webpack

    First off, thanks for the awesome plugin, and rewriting it without dependencies.

    I am using the lightgallery portion successfully, but am unable to get the plugins working. I am trying to use lg-zoom.js and lg-fullscreen.js. I tried the nested requires like you had an example of to no success. I have tried several methods of using webpack loaders for exporting or importing variables into the module. If you or any other users have an idea on how to fix this it would be greatly appreciated.

    My setup looks like

    require('lightgallery.js');
    require('lg-zoom.js');
    require('lg-pager.js');
    require('lg-fullscreen.js');
    
    export default (function () {
      $('document').ready(() => {
        lightgallery($('#lightgallery')[0]);
    
        $('.dwnld').click(function(ev) {
          ev.preventDefault();
          $(this).text('Preparing Download…');
          var $form = $('#download-form');
          $form.submit();
        });
      });
    })();
    
    v1 
    opened by chadwilken 9
  • Change video.js size

    Change video.js size

    Hi, How i can change default video.js size when i click on video its open but is small i want min-width: 100% to make it on full window and keep proportion. I cannot find it on css file Thank you

    v1 
    opened by user9823749 8
  • Mixed content warnings for gh-pages

    Mixed content warnings for gh-pages

    I tried to fix it myself but I can't checkout the gh-pages branch on Windows.

    xmr@xmr-PC ~
    $ cd /c/Users/xmr/Desktop/lightgallery.js/
    
    xmr@xmr-PC /c/Users/xmr/Desktop/lightgallery.js
    $ git checkout -b gh-pages remotes/origin/gh-pages
    fatal: cannot create directory at 'lightgallery/sass/C:': Invalid argument
    

    The fix should be pretty easy; just use https for all links and scripts.

    opened by XhmikosR 8
  • Help me >_< merge two gallery in one output

    Help me >_< merge two gallery in one output

    image

    Need merge 2 gallery in one output...

    image

    add gallery 1

    im use code

    require(["jquery", "lightgallery"], function () { require(["lg-thumbnail", "lg-fullscreen"], function () {

                lightGallery(document.getElementById("lightgallery"), {
                    selector: ".lg-item a"
                });
    
            });
    

    });

    opened by ZeoNish 6
  • Uncaught TypeError: Cannot read property 'match' of null

    Uncaught TypeError: Cannot read property 'match' of null

    I'm setting up lightgallery.js for a website and am running into an issue with it using version 0.0.3.

    The error message is:

    Uncaught TypeError: Cannot read property 'match' of null
    

    Running the non-minified script fails at line 638, which contains:

    var youtube = src.match(/\/\/(?:www\.)?youtu(?:\.be|be\.com)\/(?:watch\?v=|embed\/)?([a-z0-9\-\_\%]+)/i);
    

    Here's the relevant markup (which uses the Pure CSS framework):

    <section class="content">
      <h1 class="text-centered">Gallery</h1>
      <div id="lightgallery" class="pure-g">
        <div class="pure-u-1 pure-u-sm-1-2">
          <a href="/media/gallery/1.jpg">
            <img src="/media/gallery/1.jpg" class="pure-img">
          </a>
        </div>
        <div class="pure-u-1 pure-u-sm-1-2">
          <a href="/media/gallery/2.jpg">
            <img src="/media/gallery/2.jpg" class="pure-img" >
          </a>
        </div>
        <div class="pure-u-1 pure-u-sm-1-2">
          <a href="/media/gallery/3.jpg">
            <img src="/media/gallery/3.jpg" class="pure-img" >
          </a>
        </div>
        <div class="pure-u-1 pure-u-sm-1-2">
          <a href="/media/gallery/4.jpg">
            <img src="/media/gallery/4.jpg" class="pure-img" >
          </a>
        </div>
      </div>
    </section>
    

    And the JavaScript used to initialize it:

    <script src="/assets/js/lightgallery.js"></script>
    <script>
      lightGallery(document.getElementById('lightgallery'));
    </script>
    

    I'm not using any other JavaScript files on that site, not even jQuery. Note that it used to work for a small while, but I can't remember why.

    I can reproduce this behavior with both Chromium 52 and Firefox 48.

    opened by Calinou 6
  • Importing to React

    Importing to React

    I am trying to import this into React. I keep getting an empty object. I am not sure if I am doing it incorrectly or if there is an issue.

    import lightGallery from 'lightgallery.js';
    console.log(lightGallery); // returns Object {}
    

    thanks

    opened by yankeyhotel 6
  • Adding WOFF2 support

    Adding WOFF2 support

    Fixes #53. Also correcting typos in README.md

    Additionally, please update dist/css after the merge, so people using bower etc may profit from the changes. If there's anything else, let me know, and thanks for this great library. Cheers!

    opened by S1SYPHOS 5
  • util.js window & document getAttribute/setAttribute not working with google maps streetview

    util.js window & document getAttribute/setAttribute not working with google maps streetview

    Problem If you are using lightgallery.js with google maps on the same page (both libraries included) and want to use Google Maps Street View you will not be able to, because the lightgallery hardcoded functions for "getAttribute" and "setAttribute" on window and document will conflict with Google Maps Street View

    Request Remove these functions from window and document and use a util function instead.

    Pull Request already added to #68

    opened by hummal 5
  • destroy only works once

    destroy only works once

    Hi, I'm currently building a website and using lightGallery in combination with Justified Gallery. I ran into a problem when filtering images and therefore destroying and reinitialize lightGallery with the remaining pictures.

    As long as I haven't clicked on a picture or so to speak opened the gallery, the gallery gets correctly destroyed and repopulated with the remaining pictures after filtering (let's say with architecture-pictures). But clicking on any pictures before filtering leads to this.thumbOuter.parentNode is null in lg-thumbnail.min.js:7:8883.

    I initialize the gallery as follows:

    $(document).ready(function() {
        var gallery = document.getElementById('lightgallery');
        lightGallery(gallery, {
            selector: ".itemlg",
            mode: "lg-fade",
            hideBarsDelay: 1000
        });
    });
    

    Then filtering by clicking on a button.

    $(document).ready(function() {
        $(this).on("click", "#architecture", function() {
            //causes the error
            window.lgData[gallery.getAttribute("lg-uid")].destroy(true);
    
            jQuery("#mygallery").justifiedGallery({
                filter: ".architecture",
            });
    
            gallery = document.getElementById('lightgallery');
            lightGallery(gallery, {
                selector: ".architecture",
                mode: "lg-fade",
                hideBarsDelay: 1000
            });
        });
    });
    

    I don't think that's intended. Or maybe I missed a point.

    opened by Byggerat 5
  • Bump decode-uri-component from 0.2.0 to 0.2.2

    Bump decode-uri-component from 0.2.0 to 0.2.2

    Bumps decode-uri-component from 0.2.0 to 0.2.2.

    Release notes

    Sourced from decode-uri-component's releases.

    v0.2.2

    • Prevent overwriting previously decoded tokens 980e0bf

    https://github.com/SamVerschueren/decode-uri-component/compare/v0.2.1...v0.2.2

    v0.2.1

    • Switch to GitHub workflows 76abc93
    • Fix issue where decode throws - fixes #6 746ca5d
    • Update license (#1) 486d7e2
    • Tidelift tasks a650457
    • Meta tweaks 66e1c28

    https://github.com/SamVerschueren/decode-uri-component/compare/v0.2.0...v0.2.1

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
Releases(1.4.1-beta-0)
Owner
Sachin Neravath
Full-Time Open-Sourcerer.
Sachin Neravath
3D Infinite Art Gallery! This pulls from Reddit's r/Art and creates a procedural infinite art gallery from random (sfw-only) posts.

Infinite-Art-Gallery Click for Demo! 3D Infinite Procedurally-Generated Art Gallery! This pulls from Reddit's r/Art and creates a procedural infinite

Austin 33 Dec 15, 2022
JavaScript image gallery for mobile and desktop, modular, framework independent

PhotoSwipe v5 — JavaScript image gallery and lightbox Demo | Documentation Repo structure dist/ - main JS and CSS src/ - source JS and CSS. src/js/pho

Dmytro Semenov 22.4k Dec 29, 2022
This plugin can generate timestamps for video, audio and Bilibili video, it takes you to the corresponding video/audio position when clicked.

logseq-plugin-media-ts 本插件能够生成视频、音频以及 B 站视频的时间戳,点击时间戳后会跳转到对应的音视频位置。 This plugin can generate timestamps for video, audio and Bilibili video, it takes

Seth Yuan 58 Jan 3, 2023
Postgres.js - The Fastest full featured PostgreSQL client for Node.js and Deno

?? Fastest full-featured node & deno client ?? ES6 Tagged Template Strings at the core ??‍♀️ Simple surface API ??️ Dynamic query support ?? Chat and

Rasmus Porsager 4.3k Jan 1, 2023
A Full-Featured Modern Dashboard Template for Discord Bots

D-Dash: Discord Bot Dashboard A Full-Featured Dashboard Template for Discord Bots You can modify config/config.js to edit configuration without touchi

MONEY 33 Jan 8, 2023
A full-featured Solana Metaplex Candymachine client-side library in Typescript

Candymachine Client SDK A full-featured Solana Metaplex Candymachine client-side library in Typescript Disclaimer: The SDK is currently a pre-alpha ve

Boxfish Studio 36 Nov 10, 2022
Triumph Tech’s Magnus Editor is a full-featured remote editor for Rock RMS.

Magnus Visual Studio Code Editor for Rock RMS Triumph Tech’s Magnus Editor is a full-featured remote editor for Rock RMS. Rock RMS is an open source R

Triumph Tech 8 Nov 23, 2022
Piccloud is a full-stack (Angular & Spring Boot) online image clipboard that lets you share images over the internet by generating a unique URL. Others can access the image via this URL.

Piccloud Piccloud is a full-stack application built with Angular & Spring Boot. It is an online image clipboard that lets you share images over the in

Olayinka Atobiloye 3 Dec 15, 2022
optimize image & upload file to cloud as image bed with tiny image automic.

Rush! 图片压缩 & 直传图床工具 这是一个兴趣使然的项目, 希望 Rush! 能让这个世界的网络资源浪费减少一点点 下载 Downloads 获取最新发行版 功能 Features 拖拽批量压缩图片, 支持格式 jpg/png/gif Drop to optimize, jpg/png/gif

{ Chao } 3 Nov 12, 2022
Fast Hugo gallery theme/module suitable for lots of images.

Gallery Deluxe A Hugo Module to show a photo gallery. It's very fast/effective, especially if you have lots of images on display. See the annotated in

Bjørn Erik Pedersen 51 Jan 2, 2023
🖼 Simple file-upload utility that shows a preview of the uploaded image. Written in TypeScript. No dependencies. Works well with or without a framework.

file-upload-with-preview ?? Simple file-upload utility that shows a preview of the uploaded image. Written in TypeScript. No dependencies. Works well

John Datserakis 427 Dec 26, 2022
Incredible drastically simplifies creation of developer video content. It offers a unified workflow to storyboard, record, collaborate and produce the video.

?? Introduction Incredible drastically simplifies creation of developer video content. It offers a unified workflow to storyboard, record, collaborate

Incredible 113 Dec 6, 2022
A simple cli-app that allows you to divide a YouTube video into multiple separate videos base on a video's time stamps. Powered by pkg and yt-scissors library.

YouTube-Scissors CLI A simple CLI app that allows you to divide a YouTube video into multiple separate videos base on a video's time stamps. This proj

Gabe 23 Nov 8, 2022
A lightweight, fully-featured, modular, typescript-compatible javascript library for Paymongo.

paymongo.js A lightweight, fully-featured, modular, typescript-compatible javascript library for PayMongo. Installation npm install paymongo.js # or y

Prince Carlo Juguilon 15 Nov 23, 2022
A Javascript library that discourages and prevents image theft/download by preventing client ability to retrieve the image.

ProtectImage.js ProtectImage.js is a Javascript library that helps prevent image theft by disabling traditional user interactions to download/copy ima

null 4 Aug 18, 2022
Simple JavaScript Library to add parallax image to background-image

Backpax Simple JavaScript Library to add parallax image to background-image Install $ npm install backpax --save Demo Demo page is here Usage If you

appleple 13 Oct 12, 2022
Fully featured clean-css plugin for Visual Studio Code

vscode-clean-css Fully featured clean-css plugin for Visual Studio Code. Install Execute Extensions: Install Extensions command from Command Palette (

Shogo Sensui 2 Nov 9, 2021
An interactive app that allows adding, editing and removing tasks of a to-do list. Drag-and-drop featured added. Webpack was used to bundle all the Js modules in to one main Js file.

To-do List A to-do list app This app let you to set your own to-do list. Built With HTML CSS JavaScript WebPack Jest Live Page Page Link Getting Start

Kenny Salazar 7 May 5, 2022