width in px. Named `w{width}` so the srcset can be built from the name. */ public const WIDTHS = [ 'w160' => 160, 'w400' => 400, 'w800' => 800, 'w1200' => 1200, 'w1600' => 1600, ]; protected function registerCollectionConversions(MediaCollection $collection, HasMedia $model): void { $collection->registerMediaConversions(function (Media $media) use ($model) { foreach (self::WIDTHS as $name => $width) { $model->addMediaConversion($name) ->width($width, [Constraint::PreserveAspectRatio, Constraint::DoNotUpsize]) ->format('webp') ->quality(80); } }); } }