Simple Lightbox for WordPress
** !!! Upgrade only if your server uses PHP 8.0++. Do NOT upgrade if it still uses PHP 7.4. !!! ** Provides an easy was to add a Lightbox to Images in Gutenberg image, gallery and Media-with-Text-Blocks. Additionally to Youtube and HTML5 Videos but no other videos. Other video types like VideoPress,
** !!! Upgrade only if your server uses PHP 8.0++. Do NOT upgrade if it still uses PHP 7.4. !!! **
Provides an easy was to add a Lightbox to Images in Gutenberg image, gallery and Media-with-Text-Blocks. Additionally to Youtube and HTML5 Videos but no other videos. Other video types like VideoPress, Vimeo etc. are currently NOT supported. The Javascript library fslightbox.js is used for that. You even may use the paid version of fslightbox.js. Plugin settings are provided by a JSON-file that may be easily changed and backed-up manually (automatically after V2.0.0).
NEW: Added support for the complete HTML-code to the post, page etc. in-between body tags and not only the content. This is an Opt-in. See example settings file in ./settings/plugin-settings-body.json.
The support for HTML5-Videos and Youtube-Videos will add a small red button on the top left of the embedded Youtube-Video which opens the lightbox with that video. YT-Videos could be disabled by deleting the line "wp-block-embed-youtube" in the file plugin-settings.json . If you do so please delete the comma at the end of the line before, too! See live example here: https://www.berg-reise-foto.de/software-wordpress-lightroom-plugins/wordpress-plugins-fotos-und-karten/
The support for Youtube-Videos is working with the given functionality and extended to stop running videos onOpen and for the paid version to stop running videos on slideChange.
Plugin uses
Following libraries and WP-Plugins were used to create this plugin:
- 01fslightbox.js
- 02HTML5DOMDocument by ivopetkov
- 03Lightbox Gallery by Kodefix
A closer look.
Frequently asked questions.
How does the plugin work?
Plugin is filtering the content of posts and pages and appends lightbox effect for native Gutenberg-Blocks: Image, Gallery, Media-and-Text, Featured Image, Video and Youtube-Video. It also works for external images or YT-videos that are not on your site.
What exactly are the preconditions?
It filters the content of the page, post etc (setting: postTypes). Meaning exactly the content that WP stores in the database as content for posts, pages etc. (Using the_content filter) All elements in html figure tags and img tags will be filtered and if its CSS-Class is defined in the plugin-settings.json (setting: cssClassesToSearch).