Installation
Requirements
Section titled “Requirements”| Dependency | Version |
|---|---|
| PHP | ^8.1 |
Laravel (illuminate/*) | 10, 11, 12, 13 |
| league/glide | ^2.0 | ^3.0 |
Glide needs the gd or imagick PHP extension. Imagick is required for SVG rasterization and HEIC input, and is the safer choice for AVIF — see Drivers & formats.
Optional: enshrined/svg-sanitize for full SVG sanitization (see SVG).
Install
Section titled “Install”composer require fomvasss/laravel-imagepresetsThe service provider and the Imagepreset facade alias are registered by package discovery. The route, the @imagepreset Blade directive and the imagepreset_url() helper are available right away.
Publish the config:
php artisan vendor:publish --tag=imagepresets-configThis creates config/imagepresets.php. There are no migrations.
First steps
Section titled “First steps”-
Check the default disk. Processed images go to the
publicdisk; with the default emptypaththey land in the root of that disk, next to your uploads. Set a subdirectory:IMAGEPRESET_PATH=imagepresets -
Set the allowlists (
allowed_widths,allowed_heights,allowed_sizes, …) to the sizes your frontend uses, or define named presets. A request outside the allowlists returns 404. -
Use a cache store that supports atomic locks across all app servers (Redis, Memcached, database). The package locks each image while it is generated, see Configuration.
-
Put a CDN or a reverse-proxy cache in front of the endpoint — see HTTP caching & CDN.
Check that it works:
curl -s -o /dev/null -D - "http://your-app.test/imagepreset?src=images/photo.jpg&w=300"src is relative to the public disk, storage/ or public/ — see Image sources.