Full featured JavaScript lightbox gallery. No dependencies.
lightgallery supports all major browsers including IE 9 and above.
You can install lightgallery
using the Bower package manager.
bower install lightgallery.js --save
You can also find lightgallery
on npm.
npm install lightgallery.js
http://www.jsdelivr.com/projects/lightgallery.js
You can also directly download lightgallery from GitHub.
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'));
});
});
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>
Finally you need to initiate the gallery by adding the following code.
<script>
lightGallery(document.getElementById('lightgallery'));
</script>
If you like lightgallery please support the project by staring the repository or tweet about this project.
Author: sachinchoolur
Live Demo: https://sachinchoolur.github.io/lightgallery.js/
GitHub: https://github.com/sachinchoolur/lightgallery.js
#javascript