⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

How to simplify this



nunenthal

nunenthal
  • profile picture
  • Member

Posted 01 March 2019 - 15:09 PM

public_function upload_image()

{

$crud = $this->_getGroceryCrudEnterprise();
$crud->setFieldUpload('photo1', 'assets/images/accueil/photo1', 'assets/images/accueil/photo1');

.....

$crud->callbackAfterUpload(function ($data = null) {
    $nom=$data->filename;
         $path=$data->filePath;
        $fullPath = $path.$nom; 
        $image=new \Gumlet\ImageResize($fullPath);
        $image->resizeToBestFit(500, 300);
        $image->save($fullPath);
        return $data;
});
....
}

 

In something like this

public_function upload_image()

{

...

$crud->callbackAfterUpload(resize($data = null);
....
}
public function resize ($data)
{
    $nom=$data->filename;
        $path=$data->filePath;
        $fullPath = $path.$nom; 
        $image=new \Gumlet\ImageResize($fullPath);
        $image->resizeToBestFit(500, 300);
        $image->save($fullPath);
        return $data;
});