sandywp / plugins / fancybox-for-wordpress

FancyBox for WordPress

4.6 out of 5 stars. 4.6 92 reviews

Seamlessly integrates FancyBox lightbox into your WordPress blog: Upload, activate, and you're done. Additional configuration optional.

Launch a sandbox with this plugin → No signup.
Ready in seconds.

v3.4.2 30,000+ installs WP 5.6+ PHP 7.4+

your-sandbox.sandywp.com/wp-admin
FancyBox for WordPress running inside a SandyWP sandbox

What you get inside

4 screens
  • An image open in the lightbox, with its caption, navigation arrows and toolbar.

  • Appearance settings — overlay, padding, border, caption position and colours.

  • Gallery settings — group every image on the page, each gallery block, each post, or write your own expression.

  • Behaviour settings — closing, zoom, mouse wheel, WooCommerce, PDFs and mobile.

About this plugin

FancyBox for WordPress turns the images you already have into a lightbox gallery. Activate it and every image that links to a full-size file opens in an overlay instead of loading a new page — in posts, pages, widgets and the block editor’s gallery blocks, with no shortcodes and nothing to add to your content.

If the defaults suit you, there is nothing to configure.

What you get out of the box

  • Click any linked image to open it in an overlay, with the rest of the page dimmed behind it
  • Arrow keys, on-screen arrows, swipe on touch devices, and Escape to close
  • Zoom, slideshow, thumbnail strip and full-screen controls in the toolbar
  • Captions taken from the image title, the block editor’s caption, or a data-caption attribute
  • Galleries grouped automatically — everything on the page, per post, or per gallery block
  • PDFs, videos and other pages open in the lightbox too

What you can change

Settings live under Settings → Fancybox for WP, split into Appearance, Animations, Behaviour, Galleries and Misc:

  • Overlay colour and opacity, padding, border, background colour
  • Caption position (inside the frame, over the image, or below it), size and colour
  • Opening and transition animations, and their speed
  • Close on overlay click, close on image click, zoom on click, mouse-wheel navigation, looping
  • Turn the lightbox off on mobile, on WooCommerce shop pages, or on product pages
  • Exclude PDF links, or exclude individual images with class="nolightbox"
  • A custom jQuery expression if you want to decide exactly which links are affected

Built on FancyBox 3

The plugin bundles FancyBox 3.5.7. Nothing is loaded from an external CDN, so no visitor data leaves your site. The bundled copy is namespaced (fancyboxforwp) so it will not collide with a FancyBox that your theme or another plugin already loads.

Translations

Available in your language through WordPress.org language packs. Translations are contributed by the community at translate.wordpress.org — help for your locale is very welcome.

Contributing

Development happens on GitHub. Bug reports and pull requests are welcome.

This plugin is developed and maintained by Colorlib, who also make free WordPress themes.

If it is useful to you, a review genuinely helps.

Questions

How do I add a caption?

Three ways, and they stack:

  • Set the image’s Title in the media library or block settings — it appears under the image.
  • Add a caption in the block editor — it is picked up automatically.
  • Add data-caption to the link for longer or formatted text:

Basic HTML such as <br>, <em> and <a> is allowed. Captions are sanitised before display, so scripts and event handlers are stripped.

How do I stop one image opening in the lightbox?

Add class="nolightbox" to the link. Links from Envira Gallery and NextGen Gallery are skipped automatically so the two lightboxes do not fight.

The lightbox looks wrong — the image is cut off, stretched, or barely visible

Almost always another plugin or theme loading its own copy of FancyBox. Two stylesheets defining the same class names will fight, because FancyBox’s CSS class names are shared.

To check, open your browser’s developer tools, look at the Network tab, and search for fancybox. If you see a .css file from anywhere other than /plugins/fancybox-for-wordpress/, that is the conflict. Disabling the other lightbox, or the option in your theme that loads it, resolves it.

3.4.2 fixed the worst version of this, where the image collapsed to a thin sliver and videos played sound with no picture.

Images loaded by infinite scroll or lazy loading do not open

Fixed in 3.4.1. Thumbnails added after the page has finished loading — infinite scroll, lazy loading, AJAX filters — are now detected and bound automatically. Update if you are on an older version.

Can I load the lightbox only on certain pages?

Yes, with a filter. Put this in your theme’s functions.php or a site-specific plugin:

add_filter( 'mfbfw_is_enabled', function ( $enabled ) {
    return is_page( array( 'portfolio', 'gallery' ) );
} );

Returning false means nothing loads at all — no CSS, no JavaScript. There are also built-in switches for mobile, WooCommerce shop pages and product pages under Behaviour.

PDFs open in the lightbox. How do I stop that?

Turn on Exclude PDF files under Behaviour and PDF links will open normally.

Note that iOS Safari cannot display a PDF inside an overlay at all. If your visitors are mostly on iPhones or iPads, excluding PDFs is the more reliable choice.

How do I group images into galleries?

Under Galleries, choose how links are grouped:

  • All images on the page — one gallery for everything (default)
  • Each gallery block — one gallery per block editor gallery
  • Each post — one gallery per post on archive pages
  • No galleries — every image opens on its own
  • Custom expression — write your own jQuery selector

Does it work with WooCommerce, Elementor or other page builders?

WooCommerce has its own product image zoom, so there are switches under Behaviour to turn the lightbox off on shop and product pages.

Page builders vary. The plugin looks for links pointing at an image file, so builders that output normal image links work. Builders that render their own lightbox usually need theirs disabled first.

4.6

92 reviews

  • 5 ★ 76
  • 4 ★ 6
  • 3 ★ 2
  • 2 ★ 1
  • 1 ★ 7

Ratings come from WordPress.org. SandyWP does not collect its own reviews.

sandywp / also on the shelf

Try another plugin

  • Lightbox for WordPress with social and viral features. Show photos, gallery, PDF, videos, WooCommerce images, inline content,…

  • FancyBox

    2.8 · 4K+ installs

    Enables fancybox on all image links including BMP, GIF, JPG, JPEG, and PNG links.

  • Easy SwipeBox

    5.0 · 2K+ installs

    Easily enable the SwipeBox jQuery extension on all media links. Optimized for responsive layouts and touch devices.

Spin up a real WordPress site in seconds.

Test plugins, build a demo, hand a client a link — then squash it and start again. No local setup, no Docker.