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 |
|---|---|---|
| string | Unique identifier used as the crop key |
| string | Human-readable name shown in the preset dropdown |
| float | Aspect ratio to lock (e.g. |
| int | Output width in pixels (0 = derive from crop) |
| int | Output height in pixels (0 = derive from crop) |
| string | Output format: |
| int | Compression quality 1–100 |
Last modified: 26 June 2026