laravel-image-cache maintained by webwizardsusa
Description
Drupal-style image styles for Laravel: Variants generated on demand, when an Image is stored or on a queue, for public and private Images, with optional usage tracking.
Author
Last update
2026/11/18 18:49
(dev-main)
License
Downloads
0
Tags
Laravel Image Cache
Drupal-style image styles for Laravel. Image Styles are classes that transform an Image with Intervention Image into a Variant. Variants are generated on demand (under a lock, so only once), while the Image is stored, or on a queue, and they're tracked so deleting an Image deletes them too. Images are public or private, with temporary URLs for private ones. Optionally, models report the Images they use, and Images nothing uses any more are pruned.
Requires PHP 8.3+, Laravel 12 or 13, and the gd extension (or imagick, or the vips driver).
composer require webwizardsusa/laravel-image-cache
php artisan vendor:publish --tag=image-cache-config
php artisan vendor:publish --tag=image-cache-migrations
php artisan migrate
Usage
use Intervention\Image\Interfaces\ImageInterface;
use Webwizardsusa\ImageCache\ImageStyle;
class ThumbStyle extends ImageStyle
{
public static function name(): string
{
return 'thumb';
}
public function apply(ImageInterface $image): ImageInterface
{
return $image->cover(300, 300);
}
}
List it in config/image-cache.php ('styles' => [ThumbStyle::class]), then store Images and show their Variants:
use Webwizardsusa\ImageCache\Models\Image;
$image = Image::store($request->file('photo'));
$image->url('thumb');
<x-image-cache::image :image="$image" image-style="card" :srcset="['thumb', 'card', 'banner']" alt="A cat" />
Documentation
Read the full documentation in the docs folder.