gumlet/craft-gumlet-imagetransformer
Composer 安装命令:
composer require gumlet/craft-gumlet-imagetransformer
包简介
Gumlet image transformer for Craft CMS
README 文档
README
Adds Gumlet powered asset transforms to Craft CMS:
- Drop-in replacement for Craft CMS native image transforms and
.srcset()method - Add additional Gumlet parameters to image transforms
- Use Gumlet for CP thumbnails
- Allows
.pdffiles to be rasterized and transformed (unlike Craft CMS transforms)
The only thing you'll need to update is your filesystem Base URL to use your Gumlet domain.
Requirements
This plugin requires Craft CMS 4.0.0 or later, and PHP 8.0.2 or later.
Installation
You can install this plugin with Composer.
composer require gumlet/craft-gumlet-imagetransformer -w && php craft plugin/install gumlet-imagetransformer
Then update your filesystem Base URL to use your Gumlet domain.
Configuration
Copy config.php into Craft's config folder and rename it to gumlet-imagetransformer.php.
cp vendor/gumlet/craft-gumlet-imagetransformer/src/config.php config/gumlet-imagetransformer.php
Update the gumletDomain config setting with your Gumlet domain.
return [ 'gumletDomain' => 'your-domain.gumlet.io', 'enabled' => true, 'defaultQuality' => 80, 'defaultFormat' => 'auto', 'autoFormat' => true, ];
Usage
This plugin provides multiple ways to generate Gumlet URLs for your images:
- Automatic transformer (when configured as default) - Works with
asset.setTransform()andasset.url - Twig function - Use
gumletUrl()function in templates - Service method - Use
craft.gumlet.buildUrl()in templates
Method 1: Using Twig Function (Recommended)
The easiest way to generate Gumlet URLs is using the gumletUrl() Twig function:
{# Basic usage with transform array #} <img src="{{ gumletUrl(asset, { width: 300, height: 300 }) }}" alt="{{ asset.title }}" /> {# With additional Gumlet parameters #} <img src="{{ gumletUrl(asset, { width: 300, height: 300 }, { blur: 10, brightness: 5 }) }}" alt="{{ asset.title }}" /> {# With quality and format #} <img src="{{ gumletUrl(asset, { width: 500, height: 500, quality: 85, format: 'webp' }) }}" alt="{{ asset.title }}" />
Method 2: Using Service Method
You can also use the Gumlet service directly:
{# Basic usage #} <img src="{{ craft.gumlet.buildUrl(asset, { width: 300, height: 300 }) }}" alt="{{ asset.title }}" /> {# With Gumlet-specific parameters as third argument #} <img src="{{ craft.gumlet.buildUrl(asset, { width: 300, height: 300 }, { blur: 10 }) }}" alt="{{ asset.title }}" /> {# Without transform (just replaces domain) #} <img src="{{ craft.gumlet.buildUrl(asset) }}" alt="{{ asset.title }}" />
Method 3: Using Asset Transforms and Transformation Arrays
If the Gumlet transformer is set as the default, you can use Craft's native transform methods:
{# Set the transform #} {% do asset.setTransform({ width: 300, height: 300, }) %} {# Render the tag #} {{ tag('img', { src: asset.url, width: asset.width, height: asset.height, srcset: asset.getSrcset(['1.5x', '2x', '3x']), alt: asset.title, }) }}
Direct Transformation Array Support
You can now also pass a transformation array directly to getUrl, getWidth, and getHeight:
{% set thumb = {
mode: 'crop',
width: 100,
height: 100,
quality: 75,
position: 'top-center'
} %}
<img
src="{{ asset.getUrl(thumb) }}"
width="{{ asset.getWidth(thumb) }}"
height="{{ asset.getHeight(thumb) }}">
This works for both standard named transforms and custom arrays, and will always generate a Gumlet URL.
Note: The automatic transformer may not always be active depending on your Craft CMS configuration. Using gumletUrl() or craft.gumlet.buildUrl() is more reliable.
Adding Additional Gumlet Parameters
In addition to the standard Craft CMS transform options:
modewidthheightqualityformatpositionfill
You can also apply additional Gumlet parameters by passing them as the third argument:
{# Using gumletUrl() function #} <img src="{{ gumletUrl(asset, { width: 300, height: 300 }, { blur: 20, brightness: 10, contrast: 5 }) }}" alt="{{ asset.title }}" /> {# Using service method #} <img src="{{ craft.gumlet.buildUrl(asset, { width: 300, height: 300 }, { blur: 20, brightness: 10 }) }}" alt="{{ asset.title }}" />
Available Gumlet Parameters
Gumlet supports many transformation parameters. Some common ones include:
blur- Apply blur effect (0-100)brightness- Adjust brightness (-100 to 100)contrast- Adjust contrast (-100 to 100)saturation- Adjust saturation (-100 to 100)sharpen- Sharpen the image (0-100)rotate- Rotate image (degrees)flip- Flip image ('h' for horizontal, 'v' for vertical)watermark- Add watermarktext- Add text overlay
For a complete list of available parameters, see the Gumlet Image Transformation API documentation.
Note: This plugin uses Gumlet's standard short parameter names (w for width, h for height, q for quality, f for format). These are the default parameter names used by Gumlet's image transformation API.
Mapping
Transform Modes
Craft CMS transform modes are mapped to Gumlet fit parameters:
crop→cropfit→clipstretch→scaleletterbox→clip
Position
Craft CMS positions are mapped to Gumlet crop positions:
top-left→top-lefttop-center→toptop-right→top-rightcenter-left→leftcenter-center→centercenter-right→rightbottom-left→bottom-leftbottom-center→bottombottom-right→bottom-right
Support
For issues, questions, or contributions, please visit the GitHub repository.
License
This plugin is licensed under the MIT License. See LICENSE for details.
Credits
Developed by Anshul Bansal
gumlet/craft-gumlet-imagetransformer 适用场景与选型建议
gumlet/craft-gumlet-imagetransformer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 84 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 11 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「image」 「plugin」 「cms」 「transform」 「Craft」 「craftcms」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 gumlet/craft-gumlet-imagetransformer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 gumlet/craft-gumlet-imagetransformer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 gumlet/craft-gumlet-imagetransformer 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
CakePHP 4.x AdminLTE Theme.
GraphQL authentication for your headless Craft CMS applications.
Yii2 LightBox image galary widget uses Lightbox v2.10.0 by Lokesh Dhakar
Set Links with a specific language parameter
The Yii2 extension uses jQuery jquery.carousel-1.1.min.js and makes image carousel from php array of structure defined.
Supercharged text field validation.
统计信息
- 总下载量: 84
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 25
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-11-20