Generating thumbs on upload

Something like:

'file.create:after' => function($file) {
    $widths = [350, 750, 1250];

    if($file->isResizable()) {
        foreach($widths as $width) {
            try {
                $resizedImage = $file->resize($width)->save();
            }
            catch (Exception $e) {
                throw new Exception($e->getMessage());
            }
        }
    }
}

It might end up taking a while on big uploads though.

1 Like