henrygd/bigger-picture

High performance JavaScript lightbox gallery with a small footprint.
Supports images, video, audio, iframes, and html with no plugins necessary.
8 kB gzip vanilla / smaller if you're using Svelte.

Full Page Galleries

This gallery is only images, but media types can be mixed and matched. View code example

Video / audio / iframes

Any iframe will work. Video captions are supported. View code example

HTML

Pass HTML as a string or mount a component for more control. View on Code Sandbox

Inline Galleries

BiggerPicture can be mounted in any element, making it simple to create inline galleries. View code example

Responsive Images

Use srcset to automatically load the smallest file for the current image size, even on zoom. View code example

Captions

Basic captions are built in and can be altered with CSS.

Custom Layout Example - Thumbnails

Same gallery as above, now mounted inside a wrapper component that independently
controls thumbnails via BiggerPicture's API. View on Code Sandbox

Inline Gallery Example Code

The example below supplies data to BiggerPicture using a JavaScript object.

To create an inline gallery, use the inline option. You'll probably want to set the scale, intro, and noClose options like below.

Edit bigger-picture-basic-gallery
<div id="inline" class="inline-gallery"></div>
// example data
let items = [
  {
    img: "https://assets.henrygd.me/bp/images/janko-ferlic-SDivo1PTBDs-unsplash.jpg",
    thumb: "https://assets.henrygd.me/bp/images/janko-ferlic-SDivo1PTBDs-unsplash_thumb.jpg",
    height: "2000",
    width: "3000",
    alt: "wildlife photography of brown bear cub"
  },
  {
    img: "https://assets.henrygd.me/bp/images/corey-agopian-5y4ljzRrDFA-unsplash.jpg",
    thumb: "https://assets.henrygd.me/bp/images/corey-agopian-5y4ljzRrDFA-unsplash_thumb.jpg",
    height: "2000",
    width: "3000",
    alt: "palm trees under clear blue sky"
  },
];

// initialize BiggerPicture
let bp = BiggerPicture({
  target: document.getElementById("inline")
});

// open inline gallery
bp.open({
  items,
  inline: true,
  scale: 1,
  intro: "fadeup",
  noClose: true,
});

Responsive Image Example Code

All you have to do is pass a srcset value as img. The sizes attribute is automatically updated whenever the image dimensions change. Alternatively, you may set your own sizes value.

The map example uses three sizes: 1300, 2500, and 6000 pixels.

The 1300px image will be displayed as the starting image on small screens.

The 2500px image will be loaded as the starting image on most laptops / desktops, or if a user zooms past the 1300px size.

The 6000px image will be loaded as the starting image on very high resolution monitors, or if a user zooms past the 2500px size.

<a
	href="images/exandria-2500.webp"
	data-img="images/exandria-1300.webp 1300w, images/exandria-2500.webp 2500w, images/exandria-6000.webp 6000w"
	data-thumb="images/exandria-1300.webp"
	data-height="3376"
	data-width="6000"
	data-alt="map of critical role's exandria"
	>
	<img
		src="images/exandria-1300.webp"
		alt="map of critical role's exandria"
	/>
</a>