https://github.com/fostercommerce/imagerx-imgproxy
https://github.com/fostercommerce/imagerx-imgproxy
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/fostercommerce/imagerx-imgproxy
- Owner: FosterCommerce
- License: mit
- Created: 2025-04-18T20:51:14.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-21T14:47:12.000Z (about 1 year ago)
- Last Synced: 2025-10-11T10:49:24.451Z (8 months ago)
- Language: PHP
- Size: 13.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Imager X Imgproxy Transformer
This module provides an [imgproxy](https://imgproxy.net/) transformer for [Imager X](https://github.com/spacecatninja/craft-imager-x).
## Requirements
- Craft CMS 5.0.0+
- Imager X 5.1.0+
- PHP 8.2+
## Installation
```bash
composer require fostercommerce/imagerx-imgproxy
php craft plugin/install imagerx-imgproxy
```
## Configuration
Add the imgproxy configuration to your Imager X Imgproxy transformer config file (`config/imagerx-imgproxy.php`):
```php
return [
'baseUrl' => getenv('IMGPROXY_BASE_URL'),
'key' => getenv('IMGPROXY_KEY') ?: null,
'salt' => getenv('IMGPROXY_SALT') ?: null,
'customSignature' => getenv('IMGPROXY_CUSTOM_SIGNATURE') ?: null,
'encoded' => true,
'defaultParams' => [],
];
```
## Usage
Once installed and configured, you can use the transformer with Imager X:
```twig
{% set transformedImages = craft.imagerx.transformImage(rawImage, [
{ width: 74, height: 74 },
{ width: 120, height: 120 },
{ width: 172, height: 172 },
{ width: 254, height: 254 }
], {
mode: 'crop',
transformerParams: {
padding: 10,
background: '255:0:0',
},
}) %}
```
## Notes
Take a look at the Imgproxy [processing options](https://docs.imgproxy.net/usage/processing#processing-options) for a list of available options to use in the `defaultParams` and `transformerParams` arrays.
This transformer uses [fostercommerce/imgproxy](https://github.com/fostercommerce/imgproxy-php) under the hood. Take a look there for more usage information.