Download the PHP package jorisnoo/craft-imageboss without Composer
On this page you can find all versions of the php package jorisnoo/craft-imageboss. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jorisnoo/craft-imageboss
More information about jorisnoo/craft-imageboss
Files in jorisnoo/craft-imageboss
Package craft-imageboss
Short Description ImageBoss image CDN integration for Craft CMS with native transform fallback
License MIT
Informations about the package craft-imageboss
Craft ImageBoss
ImageBoss integration for Craft CMS with native transform fallback.
Requirements
- PHP 8.3+
- Craft CMS 5
Installation
Copy the config file to config/imageboss.php:
Configuration
Set your ImageBoss credentials in .env:
When IMAGEBOSS_SOURCE is not set, the plugin falls back to Craft's native image transforms.
Config Options
| Option | Default | Description |
|---|---|---|
source |
null |
ImageBoss source identifier |
token |
null |
HMAC token for URL signing |
apiKey |
null |
API key for cache purging |
baseUrl |
https://img.imageboss.me |
ImageBoss CDN base URL |
includeVolumeFolder |
false |
Include volume folder name in URL path |
defaultWidth |
1000 |
Default width for url() |
defaultInterval |
200 |
Step size for srcset generation |
presets |
[] |
Named preset configurations |
Presets
The plugin supports two approaches for defining presets: config-based and interface-based.
Option 1: Config-Based Presets
Define presets in config/imageboss.php:
Option 2: Interface-Based Presets
Implement the ImagePreset interface on your enum for self-contained presets:
The HasImagePresetHelpers trait provides convenience methods:
Cache Purging
When IMAGEBOSS_API_KEY is set, the plugin listens for Craft's EVENT_AFTER_REPLACE_ASSET and queues a job that sends a DELETE request to the asset's ImageBoss URL. ImageBoss then clears all cached variants of the master image. See the ImageBoss caching docs for details.
Usage
Twig
The plugin registers an imageboss template variable and Twig filters.
Fluent API
Shorthand Methods
Filters
Full Example
With a placeholder for lazy loading:
PHP
Builder Methods
| Method | Description |
|---|---|
width(int) |
Set image width |
height(int) |
Set image height |
ratio(float) |
Set aspect ratio (width/height) |
min(int) |
Minimum width for srcset |
max(int) |
Maximum width for srcset |
interval(int) |
Width step for srcset |
format(string) |
Output format override |
quality(int) |
Output quality 1-100 |
animation(bool) |
Preserve animation for animated GIFs. By default ImageBoss only processes the first frame. Combine with format('mp4') to convert to video. |
download(bool\|string) |
Force browser download. true keeps the original filename, a string sets a custom one. |
preset(string\|BackedEnum\|ImagePreset) |
Apply preset configuration |
url() |
Generate single URL |
srcset() |
Generate srcset array |
srcsetString() |
Generate srcset string |
transform() |
Get TransformResult with first(), last(), all() |
cdn(array $options = []) |
Generate passthrough URL via ImageBoss cdn operation (no transform). Falls back to the asset's native URL when no source is configured. Pass ['compression' => false] to disable ImageBoss compression. |
placeholder(?string $color) |
Generate SVG data-URI placeholder |
aspectRatio() |
Get resolved aspect ratio |
All setter methods accept null safely and return $this for chaining.
Example Output
url() returns a single URL:
srcsetString() returns a comma-separated srcset string:
When an asset has a focal point set, it's automatically included in the URL:
Assets without a focal point default to center (fp-x:0.5,fp-y:0.5) so cover crops stay centred instead of falling back to ImageBoss's smart-crop.
Features
- Responsive srcset generation with configurable width ranges and intervals
- Focal point support from Craft asset focal points
- URL signing with HMAC-SHA256
- SVG placeholder generation for lazy loading
- Named presets via config or typed enums
- Automatic fallback to Craft's native transforms
License
MIT