Search by

webwizardsusa / laravel-image-cache

webwizardsusa

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.

Package info

github.com/webwizardsusa/laravel-image-cache

pkg:composer/webwizardsusa/laravel-image-cache

Statistics

Installs: 45

Dependents: 1

Suggesters: 1

Stars: 0

Open Issues: 0

v0.3.0 2026-11-18 17:49 UTC

This package is auto-updated.

Last update: 2026-11-18 17:49:40 UTC


README

Latest version on Packagist Tests Total downloads PHP version Laravel version License

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.