How to Create a Masonry Image Gallery in WordPress

Show photos uncropped in a responsive masonry layout with a lightbox, hover effects and captions, built right in the block editor.

Masonry gallery in WordPress with mixed portrait and landscape photos in staggered columns

Square grids crop your photos. Portraits lose their heads, landscapes lose their edges, and a carefully shot portfolio ends up looking like a row of thumbnails. A masonry gallery fixes that by keeping each image’s natural shape and stacking images in columns, like bricks in a wall. It’s the go-to masonry gallery layout in WordPress for portfolios and photo-heavy pages.

In this guide you’ll build a responsive masonry gallery in the block editor with the free Masonry Image Gallery Block plugin. You’ll set columns and gaps for each device, add a lightbox and hover effects, and prepare your images so the gallery stays fast.

What Is a Masonry Layout?

A masonry layout places images in vertical columns. Each image keeps its own height, and the next image slots in directly below the shortest one above it. The result is a tight, staggered wall with no awkward gaps and no forced cropping.

You’ve seen it on mood boards, photography portfolios and design inspiration sites. It suits collections where images have mixed orientations.

Masonry vs a regular grid

LayoutBest forTrade-off
MasonryMixed portrait and landscape photos, portfolios, mood boardsLess strict alignment, so rows don’t line up
Regular gridProduct shots, team photos, logos with matching sizesImages are usually cropped to the same ratio

If all your images share the same ratio, the core Gallery block may be all you need. The WordPress Gallery block documentation explains its options. Reach for masonry when your images vary and you want to show them whole.

Meet Masonry Image Gallery Block

Masonry Image Gallery Block is a free plugin that brings a masonry layout to Gutenberg as a single image gallery block. It’s built with native Gutenberg components, so it works like the blocks you already know.

What it gives you:

  • CSS-based masonry: the layout itself is built with CSS. JavaScript is used only for the lightbox popup.
  • Responsive columns: set separate column counts for desktop, tablet and phone.
  • Adjustable gaps: control the space between images for each device.
  • Lightbox: let visitors open images full screen, powered by the lightweight fslightbox library.
  • Hover effects: choose none, zoom in, zoom out or grayscale.
  • Captions: show image captions at the top, center or bottom of each image.
  • Load only where used: scripts load only on pages that contain the block.

How to Build a Masonry Gallery in WordPress, Step by Step

Gather your images first. Ideally they’re already resized and have alt text, which we’ll cover in the image prep section below.

Step 1: Install the plugin

  1. Go to Plugins → Add New in your dashboard.
  2. Search for "Masonry Image Gallery Block".
  3. Click Install Now, then Activate.

Step 2: Add the masonry gallery block

  1. Open the page or post where you want the gallery.
  2. Click the + block inserter and search for "masonry".
  3. Insert the Masonry Gallery block. You'll see an upload placeholder.

Step 3: Add your images

  1. Upload new images or pick existing ones from the Media Library.
  2. Select all the images you want in the gallery and confirm.
  3. The block shows a live masonry preview in the editor.

The block uses the alt text and caption stored with each image in the Media Library. If an image has no alt text, the block falls back to a generic “Gallery Image” label, so fill in proper alt text before you add images.

Step 4: Set columns and gaps

  1. Select the block and open the block settings sidebar.
  2. In the gallery settings, set the number of columns for desktop.
  3. Switch to tablet and phone and set fewer columns for smaller screens.
  4. Adjust the items gutter (the gap between images, in pixels) for each device.

A good starting point is three or four columns on desktop, two on tablet and one or two on phones. Then fine-tune by eye.

Step 5: Turn on the lightbox and choose a hover effect

  1. Toggle Enable Lightbox so visitors can click an image to view it larger.
  2. Pick a hover effect: none, zoom in, zoom out or grayscale.

Grayscale works well for portfolios with a strong color palette, since images come to life on hover. Zoom effects suit product and travel photos.

Step 6: Show captions (optional)

  1. Open the caption settings and turn on Show Captions.
  2. Choose where captions appear: top, center or bottom.
  3. Add or edit captions in the Media Library if any are missing.

Step 7: Preview and publish

Preview the page, click a few images to test the lightbox, and check the layout on a phone. Then publish.

Prepare Your Images for Speed

Galleries are often the heaviest part of a page. A few minutes of prep makes a big difference.

Resize before you upload

Phone and camera photos are often far larger than any screen needs. Resize images to a sensible maximum width before uploading, especially for galleries with many images. The lightbox still shows them nicely at that size.

Use WebP

WebP files are usually much smaller than JPEG or PNG at similar quality. Google’s guide to serving WebP images explains why. Our tutorial on how to convert images to WebP in WordPress shows how to automate it on upload and in bulk.

Write real alt text

Alt text helps screen reader users and search engines understand your images. Describe what’s in the photo in a short phrase, for example “Bride and groom walking through an olive grove at sunset.” Skip “image of” and avoid stuffing keywords.

Keep galleries focused

Twelve great photos beat sixty average ones. If you have a large collection, split it into several galleries by project, client or category.

Portfolio Gallery Ideas

  • Photographers: one gallery per shoot, with captions turned off so the images speak for themselves.
  • Designers and agencies: a portfolio gallery of mockups with a zoom-in hover and short captions naming the client.
  • Restaurants and cafes: food and interior photos mixed together, which is exactly where masonry beats a square grid.
  • Real estate: property photos with the lightbox on, so buyers can view each room full screen.

Want to show a before-and-after instead of a full gallery? Try our guide to photo comparison in Gutenberg.

Best Practices for Masonry Galleries

  • Mix orientations on purpose. Masonry looks best with a blend of tall and wide images.
  • Fewer columns on mobile. Tiny thumbnails in four columns on a phone are hard to see. One or two columns work better.
  • Keep gaps consistent with your site. Match the gutter to the spacing used elsewhere on the page.
  • Put the best image first. The top-left image gets the most attention.
  • Test the lightbox on touch devices. Make sure swiping and closing feel natural on a phone.

Frequently Asked Questions

Is the masonry gallery responsive?

Yes. The block is fully responsive, and you can set different column counts and gaps for desktop, tablet and phone.

Does the masonry gallery slow down my site?

The masonry layout is built with CSS, JavaScript is used only for the lightbox, and scripts load only on pages that use the block. Image file size has the biggest impact, so resize and compress your images.

Where do the captions and alt text come from?

The block uses the caption and alt text saved with each image in the Media Library. Edit them there before adding the images to keep everything consistent.

Can I turn off the lightbox?

Yes. The lightbox is a toggle in the block settings, so you can disable it if you want a static gallery.

Conclusion: Build Your Masonry Gallery Today

A masonry gallery in WordPress shows your images the way they were meant to be seen: uncropped, well spaced and easy to browse. With Masonry Image Gallery Block you get responsive columns, a lightbox, hover effects and captions, all inside the block editor. That’s a complete masonry gallery in WordPress without a page builder.

Download Masonry Image Gallery Block for free and build your first gallery today. Then explore our other Gutenberg plugins for sliders, carousels and more.

On this page

Share

Share

Gutenbergkits

Build it faster with our blocks

15 lightweight plugins for the block editor, plus Pro versions when you need more.

Leave a Reply