Galleries and grids for any website.

One script, one stylesheet and one tag turn your photos into a filterable gallery with a full lightbox. HTML, a CMS or a framework.

  • No jQuery
  • No dependencies
  • 36 kB gzipped

Version 4.0 is a full rewrite. Using version 3? See what changed and how to upgrade.

One attribute, four layouts.

Switch the layout and the same photos move to their new places. This is the live engine: hover a photo, open one.

<media-boxes layout="masonry">
  • Filters with counts, multi-select and AND / OR
  • Search and sort
  • Load more, infinite scroll or pages
  • Deep links to a filter or an open photo
  • Lightbox with zoom, swipe, thumbnails and slideshow
  • YouTube, Vimeo and HTML slides
  • Right to left, keyboard and reduced motion

Track record

Media Boxes has 4,600+ sales on CodeCanyon and a 4.9 / 5 average rating. Its author has been an Envato Elite Author since 2012, with 15,000+ sales in total.

  • 0 dependencies
  • ~30 kB of JS, gzipped
  • ~7 kB of CSS, gzipped
  • 4 layouts
  • 5 skins
  • 10 overlay and 7 image effects

Install in three lines.

No build step. Add the stylesheet, the script and the tag, then give it items as markup or as one JSON block. Control it from your code with filter(), search(), sort() and events like mb:filter.

index.html
<link rel="stylesheet" href="media-boxes.css">
<script src="media-boxes.js" defer></script>
<media-boxes layout="masonry" columns="4"><!-- your items --></media-boxes>

Before you buy.

Does it work without jQuery?

Yes. Media Boxes has no dependencies at all: no jQuery, no Isotope and no lightbox plugin. It is one script and one stylesheet, written as a standard custom element, <media-boxes>.

Does it work on my site?

It needs a page where you can add a stylesheet, a script and some HTML. That covers plain HTML sites, CMS themes and page builders with a custom-code block, and framework projects. It is not tied to any platform.

Can I use it with WordPress?

A WordPress plugin built on the same engine is in preparation and will be available separately. Until then, the script and stylesheet work in any theme or page builder where you can add your own HTML, because the markup is plain HTML.

How do I change the colors?

Set CSS variables such as --mb-accent and --mb-radius on the element or on a parent. Light and dark are both covered, and you can force one with the theme option. Try it in the builder.

Does it support video?

Yes. YouTube and Vimeo open inside the lightbox and only load when their slide is shown. MP4 and WebM files play in a native player, and any block of HTML can become a slide. Videos can also play right inside the grid, without opening the lightbox.

Is it responsive and accessible?

Columns and gaps adapt to the width of the grid itself, and the lightbox supports swipe and pinch. Controls are real buttons and links, everything works from the keyboard, focus is always visible, and reduced-motion settings are respected.

Which browsers is it tested in?

The current versions of Chrome, Edge, Firefox and Safari, on desktop and on phones. Every release runs the full test suite in Chromium, Firefox and WebKit, including touch gestures on a simulated iPhone. Internet Explorer is not supported.

I use Media Boxes version 3. What changes in 4.0?

Version 4.0 is the same CodeCanyon item, rewritten without jQuery, so buyers of version 3 get it as a free update. It is not a drop-in replacement: the markup and options changed. Envato only lets you download the latest version, so keep a copy of your version 3 files before you update. Your sites keep working with version 3, and you can stay on it as long as you want. The migration guide maps every version 3 option to its 4.0 equivalent.

How are updates handled?

Updates are published on CodeCanyon, and you download them from your account. Your setup is plain HTML plus one JSON object of options, so updating means replacing the script and stylesheet files.

Put a better gallery on your next site.