At the moment at once I'm learning and trying, to what CodeIgniter is able to. But I stuck at multiple thumbnails making at once. Probably, I messed up my head too much using Wordpress, and trying to do something like this in Codeigniter, but anyways, here is my code
<?php
class Gallery_model extends CI_Model {
var $gallery_path;
function __construct() {
parent::__construct();
$this->load->helper('functions');
$this->gallery_path = realpath(APPPATH . '../uploads');
}
function do_upload() {
$config = array(
'allowed_types' => 'jpg|jpeg|gif|png',
'upload_path' => $this->gallery_path,
'max_size' => 2000
);
$this->load->library('upload', $config);
$this->upload->do_upload();
$image_data = $this->upload->data();
$image_sizes = array(
'thumb' => array(150, 100),
'medium' => array(300, 300),
'large' => array(800, 600)
);
foreach ($image_sizes as $resize) {
$config = array(
'source_image' => $image_data['full_path'],
'new_image' => $this->gallery_path . '-' . $resize[0] . 'x' . $resize[1],
'maintain_ration' => true,
'width' => $resize[0],
'height' => $resize[1]
);
$this->load->library('image_lib', $config);
$this->image_lib->resize();
}
}
}
At the moment, I'm able to create just an image it self, but I cant make thumbnails with this. Maybe someone could enhance the code, and get it work :)
PS - I tried just take everything after $image_sizes, put it in other independent php file, run it, and var dump the $config inside of foreach, and it seemed like working.