| 开发者 | silkalns |
|---|---|
| 更新时间 | 2026年11月9日 19:37 |
| PHP版本: | 7.4 及以上 |
| WordPress版本: | 7.1 |
| 版权: | GPLv3 or later |
| 版权网址: | 版权信息 |
data-caption attributeclass="nolightbox"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.
fancybox-for-wordpress folder to the /wp-content/plugins/ directoryThree ways, and they stack:
data-caption to the link for longer or formatted text:<a href="big.jpg" data-caption="Marble, 2019<br>120 × 60 cm"><img src="thumb.jpg"></a>
Basic HTML such as <br>, <em> and <a> is allowed. Captions are sanitised before display, so scripts and event handlers are stripped.
Add class="nolightbox" to the link. Links from Envira Gallery and NextGen Gallery are skipped automatically so the two lightboxes do not fight.
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.
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.
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.
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.
Under Galleries, choose how links are grouped:
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.
Translations come from WordPress.org language packs and install automatically. If your language is missing or incomplete, you can help at translate.wordpress.org.
It adds roughly 82 KB of minified JavaScript and 14 KB of CSS. Nothing is loaded from an external server. Define SCRIPT_DEBUG in wp-config.php if you need the unminified sources for debugging.
If you only need the lightbox on a few pages, the mfbfw_is_enabled filter above avoids loading anything elsewhere.
The support forum or GitHub. A link to a page showing the problem makes it far quicker to diagnose.
javascript: are refused, and HTML or Ajax content opened from a link is sanitized.
Security: Captions and HTML opened from a link can no longer contain styles or form fields.
Security: The custom JavaScript settings now require the unfiltered_html capability, so a site administrator on multisite can no longer change them or switch them on.
Security: A URL can no longer open another site's page in the lightbox without a click.
Security: Updated DOMPurify to 3.4.17.
Changed: Links can now set only a fixed list of per-link options through data-* attributes: type, source, caption, thumbnail, size and on/off switches. Options that accept templates or markup must be passed through the JavaScript API.
Changed: Smilies, emoji and comment avatars no longer open the lightbox.
Changed: The plugin's inline CSS and JavaScript are now added through WordPress's script and style queues. Code that removed the mfbfw_init action should use the mfbfw_is_enabled filter instead.
Fixed: With "load at footer" on and jQuery also in the footer, the lightbox did not start.
Tested with WordPress 7.1.
3.4.2
Fixed: The lightbox could collapse to a thin sliver instead of showing the image, and videos played sound with no picture. The plugin's stylesheet carried a height: auto !important rule that overrode the height FancyBox calculates for each slide. On its own it happened to work, but as soon as a second copy of FancyBox's CSS was on the page - any theme or plugin bundling its own - the content box collapsed to nothing. The rule was added in 3.2.5 for a problem that no longer exists, and has been removed.
Changed: Rewrote the plugin description and replaced the FAQ, which had answered only a question about a 2015 security release. It now covers captions, excluding images, gallery grouping, loading the lightbox on selected pages, PDFs, page builders and diagnosing conflicts with other lightboxes.
Changed: New screenshots, taken on WordPress 7.0. The previous ones were from 2016 and showed an interface that no longer exists.
Changed: Screenshots are served from the plugin directory rather than bundled in the download, which cuts the download size by about two thirds.
3.4.1
Fixed: The Title size setting had no effect. With the title positioned Inside or Over - the two positions most sites use - the caption you actually see is drawn inside the image frame, while the font-size rule was applied to a different, hidden element. (#87)
Fixed: Hovering a thumbnail showed a browser tooltip repeating the caption. The plugin copied each image's title onto its link so the lightbox could read it, and browsers render that as a tooltip. The text is now carried in a data attribute instead. A title you set yourself is left alone. (#84)
Fixed: Images loaded after the page finished rendering - infinite scroll, lazy loading, AJAX filters - were never picked up by the lightbox. New thumbnails are now detected and bound automatically. (#25, #69)
Fixed: With Zoom On Click enabled, releasing the mouse after panning a zoomed image counted as a click and zoomed it straight back out. (#105)
Fixed: The lightbox announced itself to screen readers as an unnamed dialog. It now carries an accessible name and is marked as a modal. (#104)
Fixed: Removed a dead demo link from the plugin description. (#85)
3.4.0
Fixed: Translations never loaded. The plugin declared Text Domain: mfbfw while its WordPress.org slug is fancybox-for-wordpress, and WordPress looks for language packs under the slug - so none of the community translations on translate.wordpress.org ever reached anyone. The text domain now matches the slug, which switches on the six existing language packs (es_CL, es_ES, es_VE, nl_NL, ru_RU, tr_TR) and every future one. 63 locales have translation work waiting on translate.wordpress.org.
Changed: The bundled translations were migrated onto the current strings and renamed to the new domain. German, Japanese and Polish ship in the plugin because no language pack exists for them yet; Spanish and Turkish were dropped because their WordPress.org packs are more complete and take precedence anyway.
Added: Translations now also ship as .l10n.php files, the faster format WordPress 6.5 and newer prefer, with the .mo files kept as a fallback.
Added: Regenerated languages/fancybox-for-wordpress.pot from the current source - the old template was written in 2015 and had drifted badly.
Security: Updated the bundled DOMPurify from 3.1.6 to 3.4.13, picking up the fix for the nesting-based mXSS bypass (CVE-2025-26791) in the sanitizer the plugin relies on for captions and titles.
Security: Fixed a CSS injection in the generated stylesheet. Colour and size settings were escaped with esc_html(), which only blocks "<", so a value such as blue}body{display:none} could close its own declaration block and inject arbitrary site-wide CSS. Colours are now validated as hex and sizes as integers.
Security: Fixed a potential JavaScript injection via the animation speed setting, which was written into the option object unquoted.
Security: The options sanitizer is now an allow-list. It previously started from the raw submitted array, so any key it did not explicitly name was stored untouched.
Security: Added ABSPATH guards to every PHP file, a capability check on the settings screen and the reset action, and an uninstall.php so settings are removed on delete (not only on deactivate) when that option is enabled.
Security: Removed the jQuery UI stylesheet loaded from code.jquery.com. It is now bundled, which also stops leaking admin IP addresses to a third party. The bundled copy's references to jQuery UI theme images were removed - they only ever resolved on the CDN - so the settings screen no longer fires five 404s per load.
Fixed: Missing text domain on four strings on the Support tab, and a missing translators comment, so they can now be translated.
Fixed: PHP 8 compatibility. On the first page view after activation, and on any front-end request following an update, the settings array was used before it was populated, producing a wall of "Undefined array key" warnings, an "Automatic conversion of false to array" deprecation (a fatal error under PHP 9), and a fatal TypeError if the option row was not an array. Settings are now resolved and type-normalized through a single schema before use. Verified clean on PHP 8.5.
Fixed: The settings migration only ran inside wp-admin, so a site whose first request after an update was a front-end hit rendered against an incomplete settings array.
Fixed: The Overlay, Title and Zoom On Click toggles had no effect - they were tested with isset() alone, which is always true once the key exists. They now behave as labelled.
Fixed: "Make a gallery for each Gutenberg gallery block" matched nothing on WordPress 5.9 and newer, where the gallery block renders as figure.wp-block-gallery rather than ul.wp-block-gallery.
Fixed: Zoom On Click attached a new click handler on every slide without removing the previous one.
Fixed: load_plugin_textdomain() was called with the deprecated second argument.
Fixed: Script and style versions were hardcoded to "1.3.4", so browsers kept serving stale assets after a plugin update.
Fixed: Malformed markup on the settings screen - the reset form was never closed.
Fixed: Callback and custom-expression textareas were escaped with esc_attr()/wp_kses_post() instead of esc_textarea().
Fixed: Legacy border-radius and shadow settings from FancyBox 1.x era installs are no longer discarded the first time the settings are saved.
Changed: Assets are now minified - the FancyBox script drops from 162 KB to 68 KB and the stylesheet from 18 KB to 14 KB. Define SCRIPT_DEBUG to load the readable sources.
Changed: Removed 22 unused FancyBox 1.x image files from the plugin package.
Changed: The unprefixed PLUGIN_NAME constant is no longer redefined if another plugin already declared it.
Added: mfbfw_settings and mfbfw_is_enabled filters for customizing settings and disabling the lightbox per request.
Deprecated: hexTorgba() - use mfbfw_hex_to_rgba() instead. The old function still works.
3.3.7 - 07.05.2025
Fixed: Issue with text domain loading too early (translations now load properly on the init hook)
Fixed: Improved HTML sanitization in captions with DOMPurify to prevent XSS while preserving valid HTML formatting
3.3.6 - 02.05.2025
Fixed: Security issue - Fixed XSS vulnerability in caption and title handling
3.3.5 - 12.11.2024
Fixed: Security issue
3.3.4 - 22.03.2024
Fixed: Security issue
3.3.3 - 11.05.2021
Fixed : Issue with padding and border ( https://github.com/ColorlibHQ/fancybox-for-wordpress/issues/86 )
3.3.2 - 05.03.2021
Changed: Upgrade Fancybox to latest version ( https://github.com/ColorlibHQ/fancybox-for-wordpress/issues/95 )
Fixed: Close button not showing up although option is enabled
3.3.1
Compatibility with jQuery 3.0
3.3.0
Fixed compatibility issue with WordPress 5.6
3.2.9