rllngr/kirby-thumbzer
Composer 安装命令:
composer require rllngr/kirby-thumbzer
包简介
Kirby plugin — responsive srcset images with pre-generated thumbnails and ICC profile preservation
README 文档
README
A Kirby CMS plugin that pre-generates thumbnails on file upload and renders responsive <picture> elements with srcset — including WebP conversion with optional ICC colour profile preservation. Part of the rllngr plugin set.
Features
- Auto-generates resized thumbnails on
file.create,file.replace,file.changeName,file.delete - Renders responsive
<picture>+<source>+<img>with named breakpoints - WebP output with fallback to original format
- ICC profile preservation — uses ImageMagick directly (no
-strip) for photography projects working in Adobe RGB or ProPhoto RGB - Built-in Kirby route to serve thumbnail files from
/content/(bypasses.htaccessblock) - Panel button on every image to open the ICC comparison tool
- Drop-in migration from per-project
define(THUMB_ROOT, ...)+ duplicated hooks
Requirements
- Kirby 4+
- PHP 8.1+
- ImageMagick (
convert) — required for ICC preservation, optional otherwise (falls back to Kirby's GD driver)
Installation
Via Composer (recommended — installs automatically into site/plugins/):
composer require rllngr/kirby-thumbzer
Manually — clone or copy into site/plugins/kirby-thumbzer.
Configuration
In site/config/config.php:
return [ // Project prefix — prepended to every generated thumbnail filename // e.g. 'my-project-600-photo.webp' 'thumbnails.prefix' => 'my-project-', // Named breakpoints used in the srcset and for the $breakpoint param 'thumbnails.sizes' => [ 'small' => 600, 'medium' => 1200, 'large' => 1800, 'extra-large' => 2400, ], // Output format for generated thumbnails 'thumbnails.format' => 'webp', // Compression quality (0–100) 'thumbnails.quality' => 90, // ── ICC profile preservation ────────────────────────────────────────────── // false (default) — Kirby's thumb driver, smallest file size, ICC stripped // true — ImageMagick called directly without -strip, ICC embedded // Required for Adobe RGB / ProPhoto RGB photography projects 'thumbnails.preserveICC' => false, // Path to the ImageMagick convert binary (only needed when preserveICC is true // or when using the 'im' driver) 'thumbs' => [ 'driver' => 'im', 'bin' => '/usr/local/bin/convert', ], ];
Migrating from define(THUMB_ROOT, ...)
Replace the constant definition with the config option — the plugin reads both as a fallback:
// Before (remove this) define('THUMB_ROOT', 'my-project-'); // After 'thumbnails.prefix' => 'my-project-',
Then remove the file.create:after, file.replace:after, file.changeName:after, and file.delete:after hooks from config.php — the plugin registers them automatically.
Usage
Snippet
<?php snippet('rllngr/kirby-thumbzer', [ 'image' => $image, // Kirby File object — required 'sizes' => '100vw', // CSS sizes attribute 'breakpoint' => 'large', // Max size key to include (default: extra-large) 'alt' => 'My caption', // Alt text prefix (appended with the file's alt field) 'lazy' => true, // Native lazy loading (default: true) ]) ?>
Migrating from
snippet('includes/srcset-img', ...): replace withsnippet('rllngr/kirby-thumbzer', ...)— params are identical.
The snippet renders a <picture> element with a <source type="image/webp"> and an <img> fallback. For drafts, GIFs, and SVGs it falls back to a plain <img>. For video files it renders a <video> with autoplay.
Thumbnails directory
Generated thumbnails are stored in a thumbs/ subdirectory alongside the original files:
content/
projects/
my-project/
photo.jpg
thumbs/
my-project-600-photo.webp
my-project-1200-photo.webp
my-project-1800-photo.webp
my-project-2400-photo.webp
They are served through a Kirby route (content/*/thumbs/*) — no .htaccess modifications needed.
Thumbnails tab (optional)
The plugin registers a ready-to-use panel tab blueprint under tabs/thumbzer-thumbnails. Add it to any page blueprint to get a dedicated tab showing source files and generated thumbnails:
# site/blueprints/pages/project.yml tabs: content: tabs/my-content-tab thumbnails: tabs/thumbzer-thumbnails seo: seo/page
The tab has two sections:
- Fichiers source — uploaded images (with the ICC button)
- Images optimisées — the
thumbssub-page cards showing generated thumbnails
The thumbs/ sub-page and its thumbnails.txt content file are created automatically the first time an image is uploaded to the page. The panel tab will appear as soon as the page has at least one image.
Regenerate all thumbnails
To regenerate thumbnails for the entire site — including draft and unlisted pages — without going through the panel:
GET /thumbzer/regenerate
Returns a JSON summary: { "generated": 12, "skipped": 48, "errors": [] }.
This route also creates any missing thumbs/thumbnails.txt files, so running it once on an existing project is enough to bring all pages up to date.
ICC Comparison Tool
The plugin ships a built-in page to visually compare the original file against its generated WebP thumbnail — with live ICC profile metadata loaded asynchronously.
1 — Create the content page
Create content/test-icc/test-icc.txt:
Title: Test ICC
----
Uuid: test-icc-page
----
Status: unlisted
The page will be accessible at yourdomain.com/test-icc but hidden from the panel navigation and not publicly listed.
2 — Create the file blueprint
Create site/blueprints/files/image.yml — this is the blueprint used for all uploaded images. It includes the ICC button section:
# site/blueprints/files/image.yml columns: - width: 1/2 sections: content: type: fields fields: legend: label: Légende type: textarea size: medium - width: 1/2 sections: icc: type: thumbzer-icc-button meta: type: fields fields: alt: label: Alt text type: text
3 — Assign the template in page blueprints
In every page blueprint that has a type: files section where images are uploaded, add uploads: template: image so Kirby associates uploaded images with the blueprint above:
sections: files: type: files uploads: template: image
4 — Migrate existing files (first install only)
If the project already has uploaded images without a template assigned, run this in the project root to update all image metadata files at once:
find content -name "*.jpg.txt" -o -name "*.jpeg.txt" | grep -v thumbs | while read f; do grep -q "^Template:" "$f" || printf "\n----\n\nTemplate: image\n" >> "$f" done
Comparison interface
- Left — original file, Right — generated WebP thumbnail
- Drag the handle to reveal either side
- Metadata cards show file size, colorspace, and ICC profile presence (loaded async — no delay on page open)
- Adapts to light and dark mode, matching the Kirby panel appearance
- Opens in the same tab — browser back button returns to the panel
License
MIT — Nicolas Rollinger
rllngr/kirby-thumbzer 适用场景与选型建议
rllngr/kirby-thumbzer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 14 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「Thumbnails」 「kirby」 「srcset」 「icc」 「Webp」 「kirby-plugin」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 rllngr/kirby-thumbzer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 rllngr/kirby-thumbzer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 rllngr/kirby-thumbzer 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
It is a easy and simple PHP image cropper and cache thumb manager
Simple srcset integration with SilverStripe’s HTMLEditorField
AWS Serverless Image Handler transformer for Imager X
Thumbnails for videos
Zero-dependency global `kirbylog()` helper for any content
Courier offers a convenient and painless solution for creating emails tailored for your Kirby website.
统计信息
- 总下载量: 14
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 33
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-03