1. Install and download the fslightbox.
# Yarn $ yarn add fslightbox # NPM $ npm install fslightbox --save
2. Load the main JavaScript file.
<script src="index.js"></script>
3. Insert image & video links into <a> tags as follows. To create a gallery lightbox, make sure the links have the same ‘data-fslightbox’ attribute:
<a data-fslightbox="gallery" data-caption="<h1>Example title</h1>" href="1.jpg"> An Image </a> <a data-fslightbox="gallery" data-video-poster="poster.jpg" href="1.mp4"> An HTML5 Video </a> <a data-fslightbox="gallery" data-thumb="thumbnail.jpg" href="https://www.youtube.com/watch?v=yRbM2NIpZHY"> A Youtube Video </a>
4. You can also load content from the inline elements.
<a data-fslightbox="gallery"
data-width="500"
data-height="400"
data-custom-class="fslightbox-custom"
href="#custom-source">
Custom Content
</a>
div id="custom-source"
style="display: none">
Custom content here
</div> 5. Sometimes you might need to specify the data type for each link:
<a data-fslightbox="gallery" data-type="image" href="1.jpg"> An Image </a> <a data-fslightbox="gallery" data-type="video" data-video-poster="poster.jpg" href="1.mp4"> An HTML5 Video </a> <a data-fslightbox="gallery" data-type="youtube" data-thumb="thumbnail.jpg" href="https://www.youtube.com/watch?v=yRbM2NIpZHY"> A Youtube Video </a>
6. Add custom HTML attributes using the data-attr attribute:
<a data-fslightbox="gallery" data-alt="Image Alt" href="img.jpg"> Image </a>
7. API methods.
// opens content 2 fsLightboxInstances['lightbox'].open(1); // closes the lightbox fsLightboxInstances['lightbox'].close(); // refreshes the lightbox when new content is added refreshFsLightbox();
8. Event handlers.
fsLightboxInstances['lightbox'].props.onOpen = () => console.log('Lightbox open!');
fsLightboxInstances['lightbox'].props.onClose = () => console.log('Lightbox close!');
fsLightboxInstances['lightbox'].props.onInit = () => console.log('Lightbox init!');
fsLightboxInstances['lightbox'].props.onShow = () => console.log('Lightbox show!'); 9. More props to config the lightbox.
// disables the local storage
fsLightboxInstances['gallery'].props.disableLocalStorage = true;
// sets the video poster
fsLightboxInstances['gallery'].props.videosPosters = ['1.jpg'];
// sets the max width/height of the Youtube video
fsLightboxInstances['gallery'].props.maxYoutubeDimensions = { width: 1920, height: 1080 };
// sets the space between slides
fsLightboxInstances['gallery'].props.slideDistance = 0.5;
// loads only current source
fsLightboxInstances['gallery'].props.loadOnlyCurrentSource = true;
// exists fullscreen on close
fsLightboxInstances['gallery'].props.exitFullscreenOnClose = true; v3.6.0 (05/14/2025)
v3.5.0 (02/17/2025)
v3.4.2 (02/10/2023)
v3.4.1 (02/10/2023)
v3.3.3 (01/27/2023)
v3.3 (06/24/2020)
v3.2.23 (12/26/2020)
v3.2.2 (10/24/2020)
v3.2.0 (08/15/2020)
v3.1.0 (01/25/2020)
v3.0.9 (12/14/2019)
v3.0.8 (11/16/2019)
v3.0.5 (11/02/2019)
The post Modern Fullscreen Lightbox For Images & Videos – fslightbox appeared first on CSS Script.
FORT WAYNE, Ind. (WOWO) — Fort Wayne police are investigating a life-threatening shooting that happened…
FORT WAYNE, Ind. (WOWO)— Northwest Allen County Schools is publicly responding to what district leaders…
Tennessee Gov. Bill Lee would need to call a special session to redraw Tennessee's U.S.…
Advocates for LGBTQ+ Tennesseans are urging Gov. Bill Lee to veto several bills. (Photo: John…
Between Amazon's big Gaming Week sale, Woot's Spring Sale, and Best Buy dropping some exciting…
Outspoken Marvel star Evangeline Lilly has slammed Disney for its recent round of layoffs, which…
This website uses cookies.