MediaZone Help

Crop Presets

A crop preset defines a reusable output configuration — aspect ratio, output dimensions, format, and quality — that can be selected in the cropper sidebar.

Creating a preset

Extend Codezone\MediaZone\Media\CropPreset and implement the required properties:

namespace App\Media\Crops; use Codezone\MediaZone\Media\CropPreset; class HeroImagePreset extends CropPreset { public string $key = 'hero'; public string $label = 'Hero Image'; public float $aspectRatio = 16 / 9; public int $targetWidth = 1680; public int $targetHeight = 945; public string $format = 'webp'; public int $quality = 90; }

Registering presets

Add the class to config/media.php:

'crop_presets' => [ \App\Media\Crops\HeroImagePreset::class, \App\Media\Crops\ThumbnailPreset::class, ],

Properties

Property

Type

Description

$key

string

Unique identifier used as the crop key

$label

string

Human-readable name shown in the preset dropdown

$aspectRatio

float

Aspect ratio to lock (e.g. 16/9). Use NAN for free.

$targetWidth

int

Output width in pixels (0 = derive from crop)

$targetHeight

int

Output height in pixels (0 = derive from crop)

$format

string

Output format: webp, jpg, png, avif

$quality

int

Compression quality 1–100

Last modified: 26 June 2026