Adaptive photo gallery with intelligent row layout
Download the latest release from the releases page and include the files in your project:
<link rel="stylesheet" href="/lumosaic/lumosaic.css">
<script src="/lumosaic/lumosaic.js"></script>
Create a container element:
<div id="lumosaic"></div>
Initialize the gallery:
const images = [
{ src: "https://picsum.photos/800/600?random=1", width: 800, height: 600 },
{ src: "https://picsum.photos/800/600?random=2", width: 800, height: 600 },
{ src: "https://picsum.photos/800/800?random=3", width: 800, height: 800 },
{ src: "https://picsum.photos/600/800?random=4", width: 600, height: 800 },
{ src: "https://picsum.photos/800/600?random=5", width: 800, height: 600 },
{ src: "https://picsum.photos/800/800?random=6", width: 800, height: 800 },
]
new Lumosaic("lumosaic", images).init()
That's it! Your gallery is ready.
Using an array of image objects with specified width and height.
const images = [
{ src: "https://picsum.photos/800/600?random=1", width: 800, height: 600 },
{ src: "https://picsum.photos/800/600?random=2", width: 800, height: 600 },
{ src: "https://picsum.photos/800/800?random=3", width: 800, height: 800 },
{ src: "https://picsum.photos/600/800?random=4", width: 600, height: 800 },
{ src: "https://picsum.photos/800/600?random=5", width: 800, height: 600 },
{ src: "https://picsum.photos/800/800?random=6", width: 800, height: 800 },
]
new Lumosaic("lumosaic", images).init()
Using an array of image URLs. Width and height will be calculated automatically if the shouldRetrieveWidthAndHeight option is set to true.
const images = [
"https://picsum.photos/800/600?random=1",
"https://picsum.photos/800/600?random=2",
"https://picsum.photos/800/800?random=3",
"https://picsum.photos/600/800?random=4",
"https://picsum.photos/800/600?random=5",
"https://picsum.photos/800/800?random=6",
]
new Lumosaic("lumosaic", images).init()
Using existing images from the #images element.
Data attributes data-src, data-preview, data-width, and data-height can also be used.
The #images element will be removed from the DOM.
<div id="images">
<img src="https://picsum.photos/800/600?random=1" />
<img src="https://picsum.photos/800/600?random=2" />
<img src="https://picsum.photos/800/800?random=3" />
<img src="https://picsum.photos/600/800?random=4" />
<img src="https://picsum.photos/800/600?random=5" />
<img src="https://picsum.photos/800/800?random=6" />
</div>
<div id="lumosaic"></div>
new Lumosaic("lumosaic", "images").init()
You can pass additional options to the init method to customize the gallery.
new Lumosaic("lumosaic", images).init({
maxRows: 2,
gap: 10
})
rowHeightSM
rowHeightMD
rowHeightXL
rowHeight
shouldRetrieveWidthAndHeight
fallbackImageWidth
fallbackImageHeight
maxImageRatio
minImageRatio
maxRows
stretchLastRow
shuffleImages
gap
playButtonOnVideoCover
observeWindowWidth
init(options)
shuffleImages()
replaceImages(images)
updateOptions(options)
destroy()