J1 Template support lightboxes out of the box. A lightbox is a helper module that displays enlarged, almost screen-filling versions of images and videos while dimming the rest of the web page. The technique used by Lightbox gained widespread popularity due to its simple and elegant style.
lightGallery
The lightGallery module is a fast, modular and responsive jQuery Plugin to create simple but beautiful looking, featured image and video galleries.
-
Fully responsive, HTML iframe support
-
Modular architecture with built-in plugins
-
Multiple instances per page
-
Smart image preloading and Font icon support
-
Touch support for Mobile Devices
-
Keyboard navigation and Mouse drag support for Desktops
-
Double-click|Double-tap support for fullsize view
-
Support for Youtube, Vimeo, Dailymotion, VK and HTML5 video
-
20+ Hardware-Accelerated CSS3 transitions
-
Animated thumbnails, Full screen and Image Zoom support for the Lightbox
-
Easy customizable via CSS, SCSS and Module Settings
J1 Integration
J1 Theme has fully integrated Owl Carousel V1. For the typical usage of a slide show with your content no manual configuration, no carousel initialization and no HTML code is needed. J1 Owl Carousel instances are created automatically based on a single configuration step with the Owl Carousel YAML file j1_carousel_mgr.yml
.
Module sources
The sources for J1 OWL Carousel are stored within the asset path of J1Template. You’ll find all necessary data files under /assets/theme/j1/owl_carousel_v1
:
├───css │ │ owl.carousel.css │ │ owl.carousel.min.css │ │ owl.transitions.css │ │ owl.transitions.min.css │ │ │ └───themes │ j1_template.css │ j1_samples.css ├───images │ ajax-loader.gif │ grabbing.jpg │ owl.video.play.jpg └───js owl.carousel.js owl.carousel.min.js
lightgallery API
lightgallery is a fast, modular and responsive jQuery Plugin to create simple but beautiful looking, featured image and video galleries supported by a powerful lightbox.
lightgallery consists in a core library for all basic functionality and additional plugin libraries to extend the lightbox component for your needs. lightgallery comes with a lot of options, events, and methods to customize the gallery without touching the core code. You can find both lightgallery core options, and the built in plugin options here.
Initialization
The initialization of lightgallery is done by a 4-step-sequence: Loading the CSS (1) and JS code (2) portions, placing the HTML code of the gallery (3) followed by a final setup phase to make lightgallery instances ready to use (4).
CSS load
First of all add lightgallery.css in the <HEAD> section of the document.
<head>
<link type="text/css" rel="stylesheet" href="css/lightgallery.css" />
</head>
JS load
Include jQuery and lightgallery.min.js into your document. If you want to include any lightgallery plugin you can include it after lightgallery.min.js.
</BODY>
...
<!-- lightgallery core -->
<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>
...
</HTML>
HTML Markup
lightgallery allows to use any kind of HTML Block element to create the HTML portion of a gallery.
<A>
element<a id="lightgallery_id" href="img/img1.jpg">
Click to open
</a>
<script>
$(document).ready(function() {
$('#lightgallery_id').lightGallery({
selector: 'this'
});
});
</script>
<DIV>
element<div id="lightgallery_id">
<a href="img/img1.jpg">
<img src="img/thumb1.jpg" />
</a>
<a href="img/img2.jpg">
<img src="img/thumb2.jpg" />
</a>
...
</div>
<script>
$(document).ready(function() {
$('#lightgallery_id').lightGallery();
});
</script>
<DIV>
element<div id="lightgallery_id">
<h2>Gallery title</h3>
<div class="item" data-src="img/img1.jpg">
<img src="img/thumb1.jpg" />
</div>
<div class="item" data-src="img/img2.jpg">
<img src="img/thumb2.jpg" />
</div>
...
</div>
<script>
$(document).ready(function() {
$('#lightgallery_id').lightGallery({
selector: '.item'
});
});
</script>
<UL>
element<ul id="lightgallery_id">
<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>
<script>
$(document).ready(function() {
$('#lightgallery_id').lightGallery();
});
</script>
For J1Template, a Bootstrap-based notation is used based on (unstyled) unordered lists (<ul> .. </ul>).
Each image is defined as an list item part of the Markup <li> .. </li>. To make the (thumbnail) images responsive, a class definition of the Bootstrap grid-classes like col-xs-6 col-sm-4 col-md-3 are used to display (2-3-4) images fully responsive; dependig on the size of the view port.
<!-- container for lg gallery data (id = "j1-lightgallery") -->
<div id="j1-lightgallery" class="j1-lg-galleryblock">
<div class="title">The gallery title</div> <!-- gallery title -->
<!-- ul list element for the show (id = "j1-lightgallery-ul") -->
<ul id="j1-lightgallery-ul" class="row list-unstyled">
<!-- image items, 2-3-4 per row -->
<li class="col-xs-6 col-sm-4 col-md-3"
data-src="/assets/image/img_1" <!-- for thumbnail view -->
data-sub-html="<p>The image caption text for img_1</p>"> <!-- image caption -->
<!-- for fullsize view inside the lightbox -->
<a href="#">
<img class="lg-thumbnail" src="/assets/image/img_1">
</a>
</li>
...
<!-- as many items needed -->
...
<li class="col-xs-6 col-sm-4 col-md-3"
data-src="/assets/image/img_n"
data-sub-html="<p>The image caption text for img_n</p>">
<a href="#">
<img class="lg-thumbnail" src="/assets/image/img_n">
</a>
</li>
</ul>
</div>
JS initialization
Finally you need to initiate the gallery by adding the following code.
$('#j1-lightgallery-ul').lightGallery({
mode: 'lg-fade',
...
<!-- more options -->
...
cssEasing : 'cubic-bezier(0.25, 0, 0.25, 1)'
});
Options
Name | Type | Default | Description | ||
---|---|---|---|---|---|
| string |
| Type of transition between images. lightgallery comes with lots of transition effects. See chapter Transition styles for more details. | ||
| string |
| Type of easing to be used for css animations. | ||
| string |
| Type of easing to be used for jquery animations. | ||
| number | 600 | Transition duration (in ms). | ||
| string |
| Height of the gallery. Examples: | ||
| string |
| Width of the gallery. Examples: | ||
| string | `` | Add custom class for a gallery, can be used to set different style for different galleries. | ||
| string |
| Starting animation class for the gallery. | ||
| number | 150 | lightgallery backdrop transtion duration.
| ||
| number | 6000 | Delay for hiding gallery controls in ms | ||
| boolean | false | Force lightgallery to use css left property instead of transform. | ||
| boolean | true | Allows clicks on dimmer to close gallery. | ||
| boolean | true | If | ||
| boolean | true | Whether the lightgallery could be closed by pressing the Esc key. | ||
| boolean | true | Enable keyboard navigation. | ||
| boolean | true | If | ||
| bolean | true | Enable slideEnd animation. | ||
| boolean | false | If | ||
| boolean | true | Change slide on mousewheel | ||
| boolean | true | Option to get captions from alt or title tags. | ||
| string |
| Specify where the sub-html should be appended. | ||
| boolean | false | Set to | ||
| number | 1 | Number of preload slides. will exicute only after the current slide is fully loaded. Examples: you clicked on 4th image and if preload = 1 then 3rd slide and 5th slide will be loaded in the background after the 4th slide is fully loaded. if preload is 2 then 2nd 3rd 5th 6th slides is preloaded. | ||
| boolean | true | Show Content once it is fully loaded. | ||
| string | `` | Custom selector property instead of just child. Pass | ||
| string | `` | By default selectror element is taken from only inside the gallery element. Instead of that you can tell lightgallery to select element within a specific element. Examples: | ||
| string | `` | Custom html for next control. | ||
| string | `` | Custom html for prev control. | ||
index | number | 0 | Allows to set which image or video should load initially. | ||
| string |
| Set maximum width for iframe. | ||
| boolean | true | Enable download button. By default download url will be taken from data-src|href attribute but it supports only for modern browsers. If you want you can provide another url for download via | ||
| boolean | true | Whether to show total number of images and index number of currently displayed image. | ||
| string |
| Where the counter should be appended. | ||
| number | 50 | By setting the swipeThreshold (in px) you can set how far the user must swipe for the next|prev image. | ||
| boolean | true | Enables desktop mouse drag support. | ||
| boolean | true | Enables touch support. | ||
| boolean | false | lightgallery can be instantiated and launched programmatically by setting this option to | ||
| array |
| An array of objects ( |
Transition styles
lightgallery comes with lots of transition effects used for the transition between images. Use option mode
to set the type of a transition for your gallery.
Style | Description |
---|---|
| TODO: Description to be added |
| TODO: Description to be added |
| TODO: Description to be added |
| TODO: Description to be added |
| TODO: Description to be added |
| TODO: Description to be added |
| TODO: Description to be added |
| TODO: Description to be added |
| TODO: Description to be added |
| TODO: Description to be added |
| TODO: Description to be added |
| TODO: Description to be added |
| TODO: Description to be added |
| TODO: Description to be added |
| TODO: Description to be added |
| TODO: Description to be added |
| TODO: Description to be added |
| TODO: Description to be added |
Data attributes
Name | Description |
---|---|
| The large version of the image or video. |
| The id or class name of an object(div) which contain your sub html. |
| The URL of the file which contains your sub html. |
| the id or class name of an object(div) which contain your html. Used for inserting html5 videos. |
| Poster (thumb) image of the video. |
| List of images and viewport’s max width separated by comma. |
| srcset values |
| srcset sizes |
| Set true is you want to open your URL in an HTML iframe. |
| Download URL for your image or video. Pass |
| Actual size of the image in px. Used in zoom plugin to see the actual size of the image when you doubleclick on the image. |
Methods
var $lg = $('#lightgallery');
$lg.lightGallery();
// Go to third slide
// Index starts from 0
$lg.data('lightGallery').slide(2);
Name | Parameters | Description |
---|---|---|
slide() | index | Goto a specific slide. The index of the slide starts from 0. |
goToNextSlide() | Go to next slide. | |
goToPrevSlide() | Go to previous slide. | |
destroy() |
| close or destroy the gallery. If you pass true as a parameter destroy method will destroy the gallery completely. If parameter is |
Dynamic variables
Name | Description |
---|---|
| The large version of your image or video. |
| The large version of your image or video. |
| The id or class name of an object(div) which contain your sub html. |
| The URL of the file which contain your sub html. |
| The id or class name of an object(div) which contain your html. Used for inserting html5 videos. |
| Poster (thumb) image of the video. |
| List of images and viewport’s max width separated by comma. Examples: |
| srcset values |
| srcset sizes |
| Set |
| Download URL for the image or video. Pass |
| Actual size of the image in px. Used in zoom plugin to see the actual size of the image when you doublec-lick on the image. |
Events
var $lg = $('#lightgallery');
$lg.lightGallery();
// Perform any action just before opening the gallery
$lg.on('onBeforeOpen.lg',function(event){
alert('onBeforeOpen');
});
// custom event with extra parameters
// index - index of the slide
// fromTouch - true if slide function called via touch event or mouse drag
// fromThumb - true if slide function called via thumbnail click
$lg.on('onBeforeSlide.lg',function(event, index, fromTouch, fromThumb){
console.log(index, fromTouch, fromThumb);
});
Event Type | Parameter | Description |
---|---|---|
| event | Fired immediately before the start opening. |
| event | Fired immediately after opening the gallery. |
| event, index | This event is fired when the slide content has been inserted into its slide container. |
| event, index | This event is fired when the sub-html content. Examples: title|description has been appended into the slide. |
| event, index | This event is fired once the image inside the slide has been completely loaded. |
| event, prevIndex, index, fromTouch, fromThumb | Fired immediately before each slide transition.
|
| event, prevIndex, index, fromTouch, fromThumb | Fired immediately after each slide transition. |
| event, index, fromTouch | Fired immediately before each "prev" slide transition. |
| event, index, fromTouch | Fired ired immediately before each "next" slide transition. |
| event | Fired when the user starts to drag the slide. |
| event | Fired periodically during the drag operation. |
| event | Fired when the user has finished the drag operation. |
| event | Fired when the user clicks on the slide and does not crossed the swipeThreshold value. |
| event | Fired immediately before the start of the close process. |
| event | Fired immediately once lightgallery is closed. |
Plugins
lightgallery plugins enable additional functionality to the lightbox view to display thumbnails of the gallery images as a footer line for example. Several plugins are available to make a gallery view more comfortable for the users and support your image content for …
Thumbnails Plugin
You need to include thumbnials plugin (lg-thumbnail.js) in your document to use the following options.
Name | Type | Default | Description |
---|---|---|---|
| boolean |
| Enable thumbnails for the gallery. |
| boolean |
| Enable thumbnail animation. |
| string |
| Position of selected thumbnail. Posible settings: |
| number | 100 | Width of each thumbnails. |
| number | 100 | Height of the thumbnail container including padding and border. |
| number | 5 | Spacing between each thumbnails. |
| string or false |
| If you want to use external image for thumbnail, add the path of that image inside data- attribute and set value of this option to the name of your custom attribute. |
| boolean | true | Show or hide thumbnails by default. |
| boolean | true | Whether to display thumbnail toggle button. |
| boolean | true | Pull captions above thumbnails. |
| boolean | true | Enables desktop mouse drag support for thumbnails. |
| boolean | true | Enables thumbnail touch/swipe support for touch devices. |
| number | 50 | By setting the swipeThreshold (in px) you can set how far the user must swipe for the next/prev slide. |
| boolean | true | You can automatically load thumbnails for youtube videos from youtube by setting loadYoutubeThumbnail to |
| number | 1 | You can specify the thumbnail size by setting respective number. |
| boolean | true | You can automatically load thumbnails for vimeo videos from vimeo by setting loadYoutubeThumbnail to |
| string |
| Thumbnail size for vimeo videos: |
| boolean | true | You can automatically load thumbnails for dailymotion videos from dailymotion by setting loadDailymotionThumbnail to |
Youtube ThumbSizes
Values | Size | Description |
---|---|---|
| 480x360 pixels | Player Background Thumbnail. |
| 120x90 pixels | Default Thumbnail size. |
| 120x90 pixels | Middle Thumbnail size. |
| 120x90 pixels | End Thumbnail |
| 480x360 pixels | High Quality Thumbnail. |
| 320x180 pixels | Medium Quality Thumbnail. |
| 120x90 pixels | Regular Quality Thumbnail. |
| 640x480 pixels | Standard Definition Thumbnail. |
| 1920x1080 pixels | Maximum Resolution Thumbnail. |
|
Vimeo ThumbSizes
Values | Size | Description |
---|---|---|
| 100x75 pixels | Small size Thumbnail. |
| 200x150 pixels | Medium size Thumbnail. |
| 640x360 pixels | Large size Thumbnail. |
Autoplay Plugin
You need to include autoplay plugin (lg-autoplay.js) in your document to use the following options.
Name | Type | Default | Description |
---|---|---|---|
| boolean | true | Enable gallery autoplay. |
| number | 5000 | The time (in ms) between each auto transition. |
| boolean | true | Enable a autoplay progress bar. |
| boolean | false | If |
| boolean | true` | Show or hide autoplay controls. |
| string |
| Where the autoply controls should be appended. |
Video Plugin
You need to include video plugin (lg-video.js) in your document to use the following options.
Name | Type | Default | Description |
---|---|---|---|
videoMaxWidth | string |
| Set limit for video maximal width. |
youtubePlayerParams | object |
| Read more about YouTube Player-Parameters Example:
To set youtubePlayerParams in lightGallery, you can pass an object with the desired parameters as a value for the youtubePlayerParams option in the lightGallery settings. Example:
|
vimeoPlayerParams | object |
| Change vimeo player parameters.
To set vimeoPlayerParams in lightGallery, you can pass an object with the desired parameters as a value for the vimeoPlayerParams option in the lightGallery settings. Example:
|
dailymotionPlayerParams | object |
| Read more about DailyMotion Player-Parameters |
vkPlayerParams | object |
| Change vk player parameters. |
videojs | boolean |
| Enbale videojs custom video player |
videojsOptions | object |
| Videojs player options |
Fullscreen Plugin
You need to include fullscreen plugin (lg-fullscreen.js) in your document to use the following options.
Name | Type | Default | Description |
---|---|---|---|
fullScreen | boolean |
| Enable/Disable fullscreen mode |
Pager Plugin
You need to include pager plugin (lg-pager.js) in your document to use the following options.
Name | Type | Default | Description |
---|---|---|---|
pager | boolean |
| Enable/Disable pager |
Zoomer Plugin
You need to include zoom plugin (lg-zoom.js) in your document to use the following options.
Name | Type | Default | Description |
---|---|---|---|
zoom | boolean |
| Enable/Disable zoom option |
scale | number |
| Value of zoom should be incremented/decremented |
enableZoomAfter | number in ms |
| Some css styles will be added to the images if zoom is enabled. So it might conflict if you add some custom styles to the images such as the initial transition while opening the gallery. So you can delay adding zoom related styles to the images by changing the value of |
actualSize | boolean |
| Enable actual pixel icon. |
Hash Plugin
You need to include hash plugin (lg-hash.js) in your document to use the following options.
Name | Type | Default | Description |
---|---|---|---|
hash | boolean |
| Enable/Disable hash plugin |
galleryId | number |
| Unique id for each gallery. It is mandatory when you use hash plugin for multiple galleries on the same page. |
Share Providers Plugin
You need to include share plugin (lg-share) in your document to use the following options.
Name | Type | Default | Description |
---|---|---|---|
share | boolean |
| Enable/Disable share plugin |
boolean |
| Enable Facebook share. | |
facebookDropdownText | string |
| Facebok dropdown text. |
boolean |
| Enable twitter share. | |
twitterDropdownText | string |
| Twitter dropdown text |
googlePlus | boolean |
| Enable googlePlus share. |
googlePlusDropdownText | string |
| GooglePlus dropdown text |
boolean |
| Enable pinterest share. | |
pinterestDropdownText | string |
| Pinterest dropdown text |