lightgallery
Skill này làm gì
Skill này hướng dẫn agent thêm trình xem lightGallery vào website dùng JavaScript thuần, React, Vue hoặc Angular. Skill giải thích cần cài gói nào, cần thêm plugin và kiểu dáng nào, cùng các thiết lập thường gây lỗi nhất.
Khi nào nên dùng
- ✓Khi bạn muốn một thư viện ảnh mở hình trong trình xem toàn màn hình trên website.
- ✓Khi bạn cần zoom, dải ảnh thu nhỏ hoặc video YouTube và Vimeo trong thư viện.
- ✓Khi thư viện trên website bị lỗi hoặc hoạt động kỳ lạ và bạn muốn agent tìm nguyên nhân.
Liên kết skill
https://github.com/sachinchoolur/lightGallery/blob/main/skills/lightgallery/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Tôi muốn một thư viện ảnh có ảnh thu nhỏ và zoom trên trang sản phẩm của mình.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Agent cài đúng gói lightGallery cho dự án của bạn và thêm các tính năng bạn chọn. Nó theo một công thức thiết lập chuẩn và đặt kích thước ảnh để hiệu ứng mở trông đúng.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
lightGallery
One gallery, four packages with the same features and settings:
| Stack | Package | Plugins import path |
|---|---|---|
| Vanilla JS / TypeScript | lightgallery |
lightgallery/plugins/<name> |
| React | @lightgallery/react |
@lightgallery/react/plugins/<name> |
| Vue 3 | @lightgallery/vue |
@lightgallery/vue/plugins/<name> |
| Angular | @lightgallery/angular |
@lightgallery/angular/plugins/<name> |
Plugin names: thumbnail, zoom, video, autoplay, fullscreen, share,
hash, rotate, pager, comment, mediumZoom, relativeCaption,
vimeoThumbnail, originCrop, justified. Each is a separate entry — import
only what the project uses.
Default recipe. Unless the user asks for something else, every image
gallery gets the zoom and thumbnail plugins, their two CSS files, and
lgSize: 'WIDTH-HEIGHT' (data-lg-size in markup) on every image item.
lgSize is the natural size of the full image; it drives the
zoom-from-origin animation, where the slide opens from the clicked
thumbnail and closes back to it. Without it the slide fades in. Read the
dimensions from the image files, the image optimizer or the CMS rather than
dropping the field. Leave a plugin out only when told to.
Two rules that prevent most problems
- CSS is a consumer import in every stack. The framework packages ship
no CSS. Import
lightgallery/css/lightgallery.cssplus one file per plugin (lightgallery/css/lg-thumbnail.css,lg-zoom.css, …), orlightgallery/css/lightgallery-bundle.cssfor everything. - Plugins are opt-in. A feature only exists when its plugin is passed
(
plugins: [...],plugins={[...]},:plugins="[...]",[features]="[withX()]"). Its settings are ignored otherwise.
Vanilla JavaScript
import lightGallery from 'lightgallery';
import lgThumbnail from 'lightgallery/plugins/thumbnail';
import lgZoom from 'lightgallery/plugins/zoom';
import 'lightgallery/css/lightgallery.css';
import 'lightgallery/css/lg-thumbnail.css';
import 'lightgallery/css/lg-zoom.css';
const gallery = lightGallery(document.getElementById('gallery'), {
plugins: [lgZoom, lgThumbnail],
speed: 400,
});
Markup mode: the container holds anchors; each anchor's href (or
data-src) is the full image, the inner <img> is the thumbnail, and
data-lg-size="WIDTH-HEIGHT" is the full image's natural size for the
zoom-from-origin animation. Captions come from data-sub-html. If items are
not direct children, set selector. Dynamic mode:
dynamic: true, dynamicEl: [{ src, thumb, lgSize, subHtml }] and call
gallery.openGallery(index).
Methods: openGallery(index), closeGallery(), refresh() after the
markup changed, destroy(). Events fire on the container element
(lgBeforeOpen, lgAfterSlide, …) with data in event.detail; attach
listeners before initializing.
React
'use client'; // Next.js App Router: the gallery is a client component
import { LightGallery, LightGalleryItem } from '@lightgallery/react';
import Thumbnail from '@lightgallery/react/plugins/thumbnail';
import Zoom from '@lightgallery/react/plugins/zoom';
// items: [{ src, thumb, alt, lgSize: '1600-1067' }, …]
export function Gallery({ items }) {
return (
<LightGallery plugins={[Zoom, Thumbnail]} thumbnail={{ animateThumb: true }}>
{items.map((item) => (
<LightGalleryItem key={item.src} item={item}>
<img src={item.thumb} alt={item.alt} />
</LightGalleryItem>
))}
</LightGallery>
);
}
Import the CSS in the root layout. Plugin settings are objects on props
named after the plugin (zoom={{ … }}, thumbnail={{ … }}); bare boolean
props are not valid. Callbacks are onAfterSlide, onBeforeOpen, …; the
imperative handle (ref) exposes openGallery, closeGallery,
goToSlide, nextSlide, prevSlide. Use either the controlled open
prop or the uncontrolled default for the component's whole lifetime, not
both. The package is SSR-safe; no dynamic(..., { ssr: false }) needed.
Vue 3
<script setup>
import { LightGallery, LgItem } from '@lightgallery/vue';
import Thumbnail from '@lightgallery/vue/plugins/thumbnail';
import Zoom from '@lightgallery/vue/plugins/zoom';
const items = [{ src: '/photos/1.jpg', thumb: '/photos/1-thumb.jpg', alt: 'One', lgSize: '1600-1067' }];
</script>
<template>
<LightGallery :plugins="[Zoom, Thumbnail]" :thumbnail
Câu hỏi thường gặp
Skill này hỗ trợ những framework nào?
Skill hỗ trợ JavaScript và TypeScript thuần, React, Vue 3 và Angular. Agent dùng gói phù hợp với dự án của bạn.
Vì sao thư viện mở ra mà không có hiệu ứng zoom?
Thường là vì thiếu chiều rộng và chiều cao của ảnh. Skill yêu cầu đọc kích thước từ mỗi file ảnh để hiệu ứng có thể bắt đầu từ ảnh thu nhỏ.
Tôi có cần tự thêm kiểu dáng cho thư viện không?
Có. Các gói cho framework không có kiểu dáng, nên agent nhập các file CSS vào dự án của bạn.
Chi tiết
Mô tả gốc của tác giả
Add or configure a lightGallery image/video lightbox or gallery in vanilla JavaScript, React, Vue or Angular — install, imports, plugins, CSS, settings, and the pitfalls that produce most bug reports. Use when a project needs a lightbox, photo gallery, thumbnail strip, zoomable images or a YouTube/Vimeo gallery, or when editing code that imports lightgallery or @lightgallery/*.
Độ phổ biến
- Sao GitHub
- 7.1k
- Vị trí xếp hạng
- #13596
- Giấy phép
- GPL-3.0
- Cập nhật
- 14/10/2026
Bình luận
- …
Skill tương tự
angular-developer
280kGiúp agent của bạn viết code Angular và tư vấn cấu trúc dự án, hữu ích khi bắt đầu dự án mới hoặc cải thiện hiệu suất.
frontend-a11y
280kGiúp agent của bạn làm cho giao diện web dễ tiếp cận với mọi người. Đảm bảo website và ứng dụng hoạt động tốt với trình đọc màn hình và điều hướng bằng bàn phím.
frontend-patterns
280kGiúp agent của bạn áp dụng các mẫu hiện đại trong phát triển frontend. Tối ưu hiệu năng, quản lý trạng thái và tuân theo thực hành tốt nhất với React và Next.js.