I'm attempting to resize my images on upload through Grocery Crud, but having some difficulty as I'm not sure how to access what is in the POST array so I can use it in my code.
Here is the section of my controller that does the image uploading (specifically the bit where I do the callback:
//Set up a call back function after the file has been uploaded to resize the image to save bandwidth/load times when displayed on the site
$crud->callback_before_insert(array($this, 'resize_image'));
And here is the function that I'm calling:
private function resize_image ($post_array)
{
$file_uploaded = $post_array (['image_url']);
$config = array (
'image_library' => 'gd2',
'source_image' => $file_uploaded,
'create_thumb' => FALSE,
'maintain_ratio' => TRUE,
'width' => 400,
'height' => 300);
$this->load->library('image_lib', $config);
$this->image_lib->resize();
}
The upload still works fine (i.e. no errors) but the image remains at its original size. I'm sure it's something to do with what I'm populating the $file_uploaded
variable with, but I don't know how to see what is being posted by Grocery CRUD to see what I should be using. I do have the CI profiler turned on, but I think Grocery CRUD redirects on it's processing of an uploaded before you get chance to see what's posted.
Can anyone help??