[WordPress] 外掛分享: Image & Video Lightbox

首頁外掛目錄 › Image & Video Lightbox
WordPress 外掛 Image & Video Lightbox 的封面圖片
10+
安裝啟用
尚無評分
1010 天前
最後更新
問題解決
WordPress 5.8+ PHP 7.4+ v1.0.0 上架:2023-06-12

內容簡介

外掛介紹:自動為 WordPress(古騰堡)相簿和圖片區塊,以及 GenerateBlocks 圖片區塊顯示的圖片添加 Lightbox 功能,還包括使用核心 Video Block 創建的影片,並使用 FSlightbox 库。此外掛具有輕量級的特性,不需要手動一一設置每個圖片和影片的鏈結,節省時間。你還可以通過添加 no-lightbox 類別,從光箱功能中排除特定的圖片或影片。

1. 這款外掛可以自動為哪些元素添加 Lightbox 功能?
- 古騰堡相簿和圖片區塊
- GenerateBlocks 圖片區塊
- 核心 Video Block 創建的影片

2. 如何排除某些圖片或影片不使用光箱功能?
- 添加 no-lightbox 類別

3. 透過使用此外掛,原始圖片和影片標籤是否會被更改?
- 不會,外掛將在每個圖像和使用上述區塊的影片上自動添加包裝器鏈結和必要屬性以添加光箱功能。因此,它不會對您的原始圖像和影片標籤進行任何更改,也不會向您的頁面 HTML 添加額外的權重/ DOM 深度。

4. 此外掛預設僅與哪些 WordPress 原生區塊一起使用?
- WordPress 相片庫、圖片和影片區塊以及 GenerateBlocks 圖片區塊

5. 如何啟用預設未啟用的 hover CSS?
- 使用過濾器進行啟用。

外掛標籤

開發者團隊

⬇ 下載最新版 (v1.0.0) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「Image & Video Lightbox」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

Automatically adds Lightbox functionality to images displayed by WordPress (Gutenberg) Gallery and Image Blocks, as well as GenerateBlocks Image Blocks, and also videos created by the core Video Block, using the FSlightbox library.
This lightweight plugin will automatically adds Lightbox functionality to all images displayed by

the Core Gallery Block,
the Core Image Block,
GenerateBlocks Image Block,

and videos displayed by

the core Video Block

without the needs to set each gallery/image and video link to the media file so you don’t need to set them manually one by one.
Note: You can exclude specific image/video from getting the lightbox functionality by adding no-lightbox class to the image/video element.
About The Plugin

This plugin has no settings (you can customized the default configuration using filters), hence does not add any data to the database, so you don’t need to worry about ‘database leftovers’ if you deactivate the plugin.

This plugin will automatically add the wrapper link with the necessary attribute on each image and videos that uses the blocks mentioned above to add the lightbox functionality using a few lines of inline script. So it will not make any changes to your original image and video tags (if you check from the page’s HTML source), and will not add extra weight / DOM depth to your page’s HTML.

By default, this plugin only works with the native WordPress Gallery, Image, and Video Blocks, as well as GenerateBlocks Image Blocks. You can add additional selectors using filters to make this functionality also works with other image/video blocks. If you need to, send me a request to have your image/video block included by default.

This plugin will only enqueued its assets (1 JS file) to pages/posts that use blocks, and will not enqueue assets if the page/post doesn’t use one of them.

I provided simple hover CSS which are not enabled by default. You can enable it using filter (see below).

To add other image/video block:
Add the CSS class uses by the image/video block element, e.g:
add_filter( 'use_lightbox_in', function($use_lightbox_in) {
return $use_lightbox_in . ',.your-other-plugin-block-image-parent-element img, .your-other-plugin-image-class';
} );

Add the block info/name so that this plugin will enqueued the FSlightbox JavaScripts if the block is use in a post/page, e.g:
add_filter( 'use_lightbox_if', function($use_lightbox_if) {
return $use_lightbox_if . '|| has_block( "kadence/advancedgallery" ) || has_block( "your-plugin-block-name/the-block-name" )';
} );

To only enable Lightbox Functionality on certain page/post types:
Simply use the wp_dequeue function**, e.g.:
add_action( 'wp_enqueue_scripts', function() {
if ( ! is_singular('post') ) { // only enable in single post type
wp_dequeue_script( 'image-video-lightbox' );
}
});

To only enable simple hover CSS:
add_filter('use_lightbox_css', function () {
return true;
});

Why using FSlightbox?

FSlightbox is Vanilla Javascript Lightbox Library written in pure JavaScript without jQuery or any other additional dependencies. It’s lightweight (around 9kb *gzip)!
 
The JavaScript is delayable (*yes, it’s important for me). This is the only lightbox library I found that works when the JavaScript is delayed.

 
My other Plugins:

Optimize More! – A DIY WordPress Page Speed Optimization Pack. Features:

Load CSS Asynchronously – selectively load CSS file(s) asynchronously on selected post/page types.
Delay CSS and JS until User Interaction – selectively delay CSS/JS load until user interaction on selected post/page types.
Preload Critical CSS, JS, and Font Files – selectively preload critical CSS/JS/Font file(s) on selected post/page types.
Remove Unused CSS and JS Files – selectively remove unused CSS/JS file(s) on selected post/page types.
Load Gutenberg CSS conditionally – Load each CSS of the core blocks will only get enqueued when the block gets rendered on a page.
Advance Defer JS – hold JavaScripts load until everything else has been loaded. Adapted from the legendary varvy’s defer js method *recommended for defer loading 3rd party scripts like ads, pixels, and trackers
Defer JS – selectively defer loading JavaScript file(s) on selected post/page types.
Remove Passive Listener Warnings – Remove the “Does not use passive listeners to improve scrolling performance” warning on Google PageSpeed Insights

Lazyload, Preload, and more! – This tiny little plugin (around 14kb zipped) will automatically:

lazyload your below the fold images/iframes/videos,
preload your featured images,
and add loading="eager" to your featured image and all images that have no-lazy or skip-lazy class.

Shop Extra – A lightweight plugin to optimize your WooCommerce & Business site:

Floating WhatsApp Chat Widget (can be use without WooCommerce),
WhatsApp Order Button for WooCommrece,
Hide/Disable WooCommerce Elements,
WooCommerce Strings Translations,
and many more.

Animate on Scroll – Animate any Elements on scroll using the popular AOS JS library simply by adding class names. This plugin helps you integrate easily with AOS JS library to add any AOS animations to WordPress. Simply add the desired AOS animation to your element class name with “aos-” prefix and the plugin will add the corresponding aos attribute to the element tag.

 

延伸相關外掛

文章
Filter
Apply Filters
Mastodon