Jump to content


How to simplify this


  • Please log in to reply
No replies to this topic

#1 nunenthal

nunenthal

    Member

  • Members
  • PipPip
  • 17 posts
  • LocationFrance

Posted 01 March 2019 - 03: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;
});

 






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users