felixhaeberle/kirby3-webp
Composer 安装命令:
composer require felixhaeberle/kirby3-webp
包简介
Kirby 3 CMS plugin for converting JPG, JPEG and PNG into much smaller WEBP – speed up your website!
README 文档
README
Kirby 3 CMS plugin for converting JPG, JPEG and PNG into much smaller WEBP – speed up your website! 🚀🔥
🥁 Installation
Composer
composer require felixhaeberle/kirby3-webp
Git Submodule
git submodule add https://github.com/felixhaeberle/kirby3-webp.git site/plugins/kirby3-webp
Clone or download
1️⃣ Activate the plugin
Activate the plugin in the site/config/config.php file with kirby3-webp => true.
return [
'kirby3-webp' => true
]
2️⃣ Getting started
After installing and activating the plugin, you need to serve webp files to the frontend with your server configuration.
Apache
Add the following to your .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
# Checking for WebP browser support ..
RewriteCond %{HTTP_ACCEPT} image/webp
# .. and if there's a WebP version for the requested image
RewriteCond %{DOCUMENT_ROOT}/$1.webp -f
# Well, then go for it & serve WebP instead
RewriteRule (.+)\.(jpe?g|png)$ $1.webp [T=image/webp,E=accept:1]
</IfModule>
<IfModule mod_headers.c>
Header append Vary Accept env=REDIRECT_accept
</IfModule>
<IfModule mod_mime.c>
AddType image/webp .webp
</IfModule>
NGINX
For NGINX, use the following virtual host configuration:
// First, make sure that NGINX' `mime.types` file includes 'image/webp webp'
include /etc/nginx/mime.types;
// Checking if HTTP's `ACCEPT` header contains 'webp'
map $http_accept $webp_suffix {
default "";
"~*webp" ".webp";
}
server {
// ...
// Checking if there's a WebP version for the requested image ..
location ~* ^.+\.(jpe?g|png)$ {
add_header Vary Accept;
// .. and if so, serving it
try_files $1$webp_ext $uri =404;
}
}
⚙️ Options
You have multiple options when using kirby3-webp to configure it to your needs:
| Option | Type | Default | Description |
|---|---|---|---|
kirby3-webp.quality |
Integer | 90 |
See the Auto quality section. |
kirby3-webp.maxQuality |
Integer | 85 |
Only relevant for jpegs and when quality is set to "auto". |
kirby3-webp.defaultQuality |
Integer | 85 |
|
kirby3-webp.metadata |
Array | "none" |
Valid values: "all", "none", "exif", "icc", "xmp". Note: Currently only cwebp supports all values. gd will always remove all metadata. ewww, imagick and gmagick can either strip all, or keep all (they will keep all, unless metadata is set to none) |
kirby3-webp.encoding |
Array | "auto" |
See the Auto selecting between lossless/lossy encoding section. |
kirby3-webp.skip |
Boolean | false |
If true, conversion will be skipped (ie for skipping png conversion for some converters) |
👏 Credit
🤩 How this plugin works
🤯 Good to know
Sometimes, if the pictures are really big (multiple MB's) the converting process takes naturally longer, but does complete for sure. The .webp gets generated, but not selected, because if the client can accept .webp, the .webp is sent to the client instead of the .png, .jpeg or .jpg. Therefore, you are in need of the Apache/nginx configuration.
felixhaeberle/kirby3-webp 适用场景与选型建议
felixhaeberle/kirby3-webp 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7.74k 次下载、GitHub Stars 达 38, 最近一次更新时间为 2020 年 05 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 felixhaeberle/kirby3-webp 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 felixhaeberle/kirby3-webp 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 7.74k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 38
- 点击次数: 19
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-05-25


