huttchdev/craft-webpme
Composer 安装命令:
composer require huttchdev/craft-webpme
包简介
Get a WebP image url if the visitors browser and the server both support WebP
README 文档
README
Simple function that returns a WebP formatted image url if the visitors browser and the server supports WebP, if not then it will fallback to a standard image url.
- If both the server and visitors browser supports WebP, the passed image will be converted to WebP unless the passed image is a SVG.
- If the visitors browser does not support WebP then the image will not be converted and will maintain its current format.
- If the passed image is already a WebP image but the visitors browser does not support WebP then the image will be converted to a PNG (incase of transparency).
Usage
WebP Twig Function
Example:
<img src="{{ WebP(entry.image.one(), {'mode': 'crop', 'height': '600', 'width': '800'}) }}"/>
WebP(image asset, craft image transform params)
Using Preset Image Transforms
Example:
<img src="{{ WebP(entry.image.one(), {transform: 'headerImage'}) }}
Image Transform Params
Any craft support image parameters can be used See Docs
Possible Params:
{
transform: 'headerImage', // (optional) pass to use preset image transform created in the CMS admin panel, optionally add other params in combination with this to override preset settings
height: 300, // set height
width: 800, // set width
mode: 'crop', // set transform mode (crop, fit, letterbox, stretch)
quality: 80, // ovveride quality settings
position: 'top-center' // override default center position when no focal point (supported when using 'crop' or 'letterbox')
}
Optional Function Name Variations (for your preference)
WebP()
webp()
WebPMe()
webpMe()
webpme()
IsWebPSupported Twig Function
Useful for cache keys, to gnerate a cache version for webp support and one without when using {% cache %}
e.g. {% cache using key 'header-' ~ IsWebPSupported %} View Docs
IsWebPSupported
Return true or false depending on server and visitor browser support
huttchdev/craft-webpme 适用场景与选型建议
huttchdev/craft-webpme 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.35k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2023 年 01 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「image」 「compression」 「url」 「support」 「Webp」 「optimise」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 huttchdev/craft-webpme 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 huttchdev/craft-webpme 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 huttchdev/craft-webpme 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Asset Management for PHP
Image optimization / compression library. This library is able to optimize png, jpg and gif files in very easy and handy way. It uses optipng, pngquant, pngcrush, pngout, gifsicle, jpegoptim and jpegtran tools.
Yii2 LightBox image galary widget uses Lightbox v2.10.0 by Lokesh Dhakar
The Yii2 extension uses jQuery jquery.carousel-1.1.min.js and makes image carousel from php array of structure defined.
Easy URL rewrites in your Laravel application
The Yii2 extension uses jQuery PrettyPhoto and OwlCarousel js and makes image galary from php array of structure defined.
统计信息
- 总下载量: 3.35k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-01-28