Home

Awesome

lightgallery.js

travis bower npm

Full featured JavaScript lightbox gallery. No dependencies.

lightgallery

Important notice

Any questions, ideas, suggestions about v2? please start a discussion.

New features

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]

});
data-video='{"source": [{"src":"/videos/video1.mp4", "type":"video/mp4"}], "attributes": {"preload": false, "controls": true}}'



Main features

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 <a href="https://twitter.com/intent/tweet?original_referer=https%3A%2F%2Fabout.twitter.com%2Fresources%2Fbuttons&ref_src=twsrc%5Etfw&text=lightgallery%20-%20Full%20featured%20%23javascript%20lightbox%20gallery%2C%20No%20%23jQuery%20-%20http%3A%2F%2Fbit.ly%2F2amlfJe" target="_blank">tweet</a> 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.