Resizing uploaded images in Panel

A question related to the thread here : sRGB conversion and resize upon upload… which unfortunately doesn’t works for me.

I’ like to know if the function upload or checkUpload inthe class FilesController can be extended to pass a SimpleImage fuction like :

   if($file = $upload->file()) {
      try {
        $this->checkUpload($file, $blueprint);
        kirby()->trigger('panel.file.upload', $file);
        if($file->type() == 'image' ) {

          $img = new Media($file);

          thumb($img, array('width' => 1200, 'height' => 1200));

        return response::success('success');
      } catch(Exception $e) {
        return response::error($e->getMessage());
    } else {
      return response::error($upload->error()->getMessage());

I obviously tried this and no luck…
Can someone leads me to the right way to simply add a resize function that triggers when an image is uploaded to the panel other than set a max height/width in the blueprint ?

1 Like