create more than 2 thumbnails using ci |
[eluser]dsi[/eluser]
hi, i am trying to create 1 main uploaded file and 2 other different size thumbnails. i have successfully created the first thumbnail but couldnot create 2nd thumbnail, can anyone help. i have created a function for main upload file, it will call 2nd function for 1st thumbnail creation. I tried to call 3rd function for 2nd thumbnail generation but it doesnot work. I tried calling from both functions. any suggestions? here is my file upload class Code: class Upload_model extends Model{
[eluser]dsi[/eluser]
and there's another problem, when i return false in 3rd function it still uploads the file, but not the thumbnails. can anyone help?
[eluser]cahva[/eluser]
Does it create the thumbnails if you use this: Code: function _create_thumbnails($filename)
[eluser]391[/eluser]
<?php class Img extends Controller { public function __construct() { parent::Controller(); $this->load->library("image_lib"); $this->load->helper("form"); } public function index() { $this->load->view('image',array('error'=>'')); } public function do_upload() { $config['upload_path'] = './images/'; //cung cap voi system $config['allowed_types'] = 'gif|jpg|png'; //the loai upload vao $config['max_size'] = '2040'; $config['remove_spaces'] = true; $config['max_width'] = '1024'; $config['max_height'] = '768'; $this->load->library('upload',$config); if ( ! $this->upload->do_upload('image')) { $error = array('error' => $this->upload->display_errors()); $this->load->view("v_image", $error); } else { $image = array('upload_data' => $this->upload->data()); $thumbnail='./images/'."thumb_".$image['upload_data']['file_name']; $featured='./images/'.'/featured/'."thumb_".'$image['upload_data']['file_name']; $up['image_library'] = 'gd2'; $up['source_image'] = './images/'.$image['upload_data']['file_name']; $up['create_thumb'] = TRUE; $up['maintain_ratio'] = TRUE; $up['width'] = 200; $up['height'] = 121; $this->image_lib->initialize($up); $this->image_lib->resize(); //echo "Upload ok"; } } } ?> //U can try it...
[eluser]dsi[/eluser]
to 391: u have set 2 variables with their filenames and location but how are those images actually being created? will they be automatically created or r u missing something??
[eluser]391[/eluser]
i don't understand your question.If u difficult about upload image and thumbnail..U can send i. your email.i'll send code u...hope help u..my mail: [email protected]
[eluser]Satlavida[/eluser]
[quote author="391" date="1272464489"]<?php class Img extends Controller { public function __construct() { parent::Controller(); $this->load->library("image_lib"); $this->load->helper("form"); } public function index() { $this->load->view('image',array('error'=>'')); } public function do_upload() { $config['upload_path'] = './images/'; //cung cap voi system $config['allowed_types'] = 'gif|jpg|png'; //the loai upload vao $config['max_size'] = '2040'; $config['remove_spaces'] = true; $config['max_width'] = '1024'; $config['max_height'] = '768'; $this->load->library('upload',$config); if ( ! $this->upload->do_upload('image')) { $error = array('error' => $this->upload->display_errors()); $this->load->view("v_image", $error); } else { $image = array('upload_data' => $this->upload->data()); $thumbnail='./images/'."thumb_".$image['upload_data']['file_name']; $featured='./images/'.'/featured/'."thumb_".'$image['upload_data']['file_name']; $up['image_library'] = 'gd2'; $up['source_image'] = './images/'.$image['upload_data']['file_name']; $up['create_thumb'] = TRUE; $up['maintain_ratio'] = TRUE; $up['width'] = 200; $up['height'] = 121; $this->image_lib->initialize($up); $this->image_lib->resize(); //echo "Upload ok"; } } } ?> //U can try it...[/quote] Thanks... |
Welcome Guest, Not a member yet? Register Sign In |