jQuery lightGallery
Demo
JQuery lightGallery demo
Description
JQuery lightGallery is a lightweight jQuery lightbox gallery for displaying image and video gallery
what's new
- Animated thumbnails.
- Local html5 video support
- Custom Html inseted of caption and description.
- Custom selector property insted of just child.
- destroy() method.
- isActive() to check gallery active state.
- iframe support.
- showAfterLoad settings to show content once it is fully loaded
- Callback parameter(plugin).
- HTML support. inline and external.
- currentPagerPosition setting to set Position of selected thumbnail.
- Show Thumbnail by default option.
Main Features
- Responsive layout.
- Touch support for mobile devices.
- Animated thumbnails.
- CSS transitions with jQuery fallback
- Youtube Vimeo Video and html5 videos Support
- Slide and Fade Effects
- Chrome, Safari, Firefox, Opera, IE7+, IOS, Android, windows phone.
- HTML iframe support.
- Multiple instances on one page
- Easily customizable via CSS and Settings
- Lightweight (7kb) (minified)
- Separate images for mobile devices
- Can be extended with callbacks
- Smart image preloading and code optimization
- Keyboard Navigation for desktop
- Font icon support
How to use lightGallery?
Bower
You can Install lightgallery using the Bower package manager.
$ bower install lightgallery
npm
You can also find lightgallery on npm.
$ npm install lightgallery
The code
add the Following code to the <head> of your document.
<link type="text/css" rel="stylesheet" href="css/lightGallery.css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="js/lightGallery.js"></script>
// Do not include both lightGallery.js and lightGallery.min.js
HTML Structure
Create ul and li elements and add the path of the image or video inside the data-src attributes which you wish to open within the lightGallery.
<ul id="lightGallery">
<li data-src="img/img1.jpg">
<img src="img/thumb1.jpg" />
</li>
<li data-src="img/img2.jpg">
<img src="img/thumb2.jpg" />
</li>
...
</ul>
Data attributes
<li data-responsive-src="mobile1.jpg" > </li>
<li data-src="img1.jpg" > </li>
<li data-html="video html" /> </li>
<li data-html="#inlineHtml" > </li>
<li data-sub-html="<h3>My caption</h3><p>My description..</p>" /> </li>
<li data-sub-html="#inlineSubHtml" > </li>
<li data-iframe="true" data-src="http://www.w3schools.com/" > </li>
Call lightGallery!
<script type="text/javascript">
$(document).ready(function() {
$("#lightGallery").lightGallery();
});
</script>
Play with settings
<script type="text/javascript">
$(document).ready(function() {
$("#lightGallery").lightGallery({
mode: 'slide',
useCSS: true,
cssEasing: 'ease',
easing: 'linear',
speed: 600,
addClass: '',
closable: true,
loop: false,
auto: false,
pause: 4000,
escKey: true,
controls: true,
hideControlOnEnd: false,
preload: 1,
showAfterLoad: true,
selector: null,
index: false,
lang: {
allPhotos: 'All photos'
},
counter: false,
exThumbImage: false,
thumbnail: true,
showThumbByDefault:false,
animateThumb: true,
currentPagerPosition: 'middle',
thumbWidth: 100,
thumbMargin: 5,
mobileSrc: false,
mobileSrcMaxWidth: 640,
swipeThreshold: 50,
enableTouch: true,
enableDrag: true,
vimeoColor: 'CCCCCC',
videoAutoplay: true,
videoMaxWidth: '855px',
dynamic: false,
dynamicEl: [],
onOpen : function(el) {},
onSlideBefore : function(el) {},
onSlideAfter : function(el) {},
onSlideNext : function(el) {},
onSlidePrev : function(el) {},
onBeforeClose : function(el) {},
onCloseAfter : function(el) {},
});
});
</script>
In-depth explanation of settings can be found on a separate page.
Public methods
<script type="text/javascript">
$(document).ready(function() {
var gallery = $("#lightGallery").lightGallery();
gallery.isActive();
gallery.destroy();
});
</script>