Skip to content

Core: Images

Images::make, alterations, picture/srcset, versioning, and auto-alt.

Core image handling wraps Intervention Image with stream-aware URL generation, alterations, and responsive output.

Creating images

example.php
use Streams\Core\Support\Facades\Images;

$url = Images::make('storage://uploads/photo.jpg')
    ->resize(800, 600)
    ->crop(400, 400)
    ->url();

Images::make() accepts path strings or arrays and detects local, remote, and storage sources.

Alterations

Alterations chain via __call() — common methods include resize, crop, fit, widen, heighten, blur, greyscale, and quality.

Responsive output

example.php
Images::make('photo.jpg')->picture();
Images::make('photo.jpg')->srcset();
Images::make('photo.jpg')->img();

srcset() without arguments uses the current image URL, including its alterations. Use srcsets() for candidates keyed by positive integer widths (640w) or positive decimal densities (1.5x):

example.php
Images::make('photo.jpg')->srcsets([
    '320w' => ['resize' => [320, 240], 'quality' => 80],
    '640w' => ['resize' => [640, 480], 'quality' => 80],
])->img();

Each candidate must be an array of named image alterations, registered macros, or quality, rename, and version options. An optional source must be a non-empty path or URL. Invalid descriptors, candidate shapes, sources, or method names raise InvalidArgumentException before any candidate is generated. srcsets() does not add a sizes attribute.

Configuration

Key Purpose
streams.core.auto_alt Generate alt text when missing
streams.core.version_images Append version query for cache busting

Related