⚠ 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 forum is read-only and soon will be archived. ⚠


Kun Hernowo Putra

Member Since 22 Jan 2014
Offline Last Active Aug 18 2014 01:11 PM
-----

Posts I've Made

In Topic: image size problem

24 February 2014 - 04:27 AM

Hello Amit  cani upload resize image this 

 public function banner(){
        
        
        if($this->session->userdata('logged_in')){
            $session_data = $this->session->userdata('logged_in');
            $data['username'] = $session_data['username'];
            $this->load->view('administrator', $data);
        }
        else{
            redirect('login','refresh');
        }
        
        $crud = new grocery_CRUD();
        $crud->set_table('banner');
        $crud->set_subject('Banner');
        $crud->required_fields('bannerImage','bannerImage600','bannerImage370','bannerTitle','active');
        $crud->columns('bannerTitle','bannerDescription','bannerImage','active');
        $crud->display_as('sortOrder', 'Sort Order');
        $crud->display_as('bannerTitle', 'Banner Title');
        $crud->display_as('bannerDescription', 'Banner Description');
        $crud->display_as('bannerImage', 'Banner Image Large');
		$crud->display_as('bannerImage600', 'Banner Image Medium');
		$crud->display_as('bannerImage370', 'Banner Image Small');
        $crud->field_type('dateAdd', 'hidden');
        $crud->field_type('dateEdit', 'hidden');
        
        $crud->set_field_upload('bannerImage','../images/banner');
		$crud->set_field_upload('bannerImage370','../images/banner');
		$crud->set_field_upload('bannerImage600','../images/banner');
        $crud->set_relation('active','aktivasi','active');
        
		$crud->callback_after_upload(array($this,'example_callback_after_upload'));
        $crud->callback_before_delete(array($this, 'delete_banner_image'));
        $crud->unset_export();
        $crud->unset_print();
        
        $output = $crud->render();
        $this->banner_crud($output);
              
    }

    public function banner_crud($output = NULL){
        
        $this->load->view('banner.php',$output);
    }
    
	function example_callback_after_upload($uploader_response,$field_info, $files_to_upload)
{
    $this->load->library('image_moo');
 
    //Is only one file uploaded so it ok to use it with $uploader_response[0].
    $bannerImage = $field_info->upload_path.'/'.$uploader_response[0]->name; 
	$bannerImage600 = $field_info->upload_path.'/'.$uploader_response[0]->name;
	$bannerImage370 = $field_info->upload_path.'/'.$uploader_response[0]->name;
 
    $this->image_moo->load($bannerImage)->set_jpeg_quality(90);
	$this->image_moo->load($bannerImage600)->resize_crop(600,600)->save($bannerImage600,true);
	$this->image_moo->load($bannerImage370)->resize_crop(370,370)->save($bannerImage370,true);
 
    return true;
}

With my datebase
$bannerImage600 and $bannerImage370


In Topic: Grocerycrud callback_after_upload() has not effect

17 February 2014 - 09:22 AM

 

I am trying to use grocery crud for generating crud. One of my forms requires the image to thumbnailed on the fly. For this I resorted to callback->after->upload() provided in the grocery crud. But it simply doesn't get fired. Here is my controller code:
 

class Categories extends CI_Controller {

public function __construct()
{
parent::__construct();

$this->load->library('grocery_CRUD');
}

public function index()
{

$crud = new grocery_CRUD();
$crud->set_table('categories');
$crud->set_subject('Category');
$crud->required_fields('name');
$crud->unset_export();
$crud->unset_print();
$crud->unset_read();
$crud->set_field_upload('image','assets/uploads/files');
$crud->callback_after_upload(array($this,'thumbnailer'));

//$crud->columns('city','country','phone','addressLine1','postalCode');

$output = $crud->render();

$this->load->view('gcrud',$output);


}

   public function thumbnailer($uploader_response,$field_info,$files_to_upload)
{
      
       
        $this->load->library('image_moo');

                  $source=$field_info->upload_path."/".$uploader_response[0]->name;
              
                  $thumbnails=$field_info->upload_path.'/thumbnails/'.$uploader_response[0]->name;
                  $large_images=$field_info->upload_path.'/large_images/'.$uploader_response[0]->name;
                  $this->image_moo->load($source)->resize(180,350)->save($thumbnails,false);
  $this->image_moo->load($source)->resize(400,600)->save($large_images,false);
                  return true;
                              
}


}
 
It works like there is no such line "$crud->callback_after_upload(array($this,thumbnailer))"
Tried Everything. Clueless!
 

 

 

 

hello mrinal
i have a problem with my upload image by url
can u help me 

public function product(){
   
        
        if($this->session->userdata('logged_in')){
            $session_data = $this->session->userdata('logged_in');
            $data['username'] = $session_data['username'];
            $this->load->view('administrator', $data);
        }
        else{
            redirect('login','refresh');
        }
        
        $crud = new grocery_CRUD();
        $crud->set_table('product');
        $crud->set_subject('Product');
        $crud->required_fields('productName');
        $crud->columns('productCategoryId','productName', 'productDescription','active');
        $crud->display_as('productCategoryId', 'Product Category');
        $crud->display_as('productName', 'Product Name');
        $crud->display_as('productDescription', 'Product Description');
        $crud->display_as('imageDefault', 'Image');
$crud->display_as('imageBack', 'Image Back');
        $crud->display_as('sortOrder', 'Sort Order');
        $crud->field_type('dateAdd', 'hidden');
        $crud->field_type('dateEdit', 'hidden');
$crud->set_field_upload('imageDefault','../images/product/');
        /*
        $crud->set_field_upload('imageDefault','../images/');
        $crud->set_field_upload('image1','../images/');
$crud->set_field_upload('image2','../images/');
        $crud->set_field_upload('image3','../images/');
$crud->set_field_upload('imageBack','../images/');
$crud->callback_before_insert(array($this,'set_image'));
*/
//$crud->callback_after_upload(array($this,'set_image1'));

$crud->callback_before_insert(array($this,'set_image1'));
        $crud->set_relation('productCategoryId', 'product_category', 'categoryURL');
$crud->set_relation('active','aktivasi','active');

        $crud->unset_export();
        $crud->unset_print();
        
        $output = $crud->render();
        $this->product_crud($output);
              
    }

    public function product_crud($output = NULL){
        
        $this->load->view('product.php',$output);
    }  

function set_image1($post_array) {

$this->db->select('product_category.categoryURL');
$this->db->from('product_category');
$this->db->where('id',$post_array);
$post_array['categoryURL'] = $post_array['categoryURL'] . $post_array['imageDefault'];

return $post_array;
}  

     

Tq before


In Topic: How can I change upload path according to the date?

07 February 2014 - 06:11 AM

public function lookbook_image(){
        
        
        if($this->session->userdata('logged_in')){
            $session_data = $this->session->userdata('logged_in');
            $data['username'] = $session_data['username'];
            $this->load->view('administrator', $data);
        }
        else{
            redirect('login','refresh');
        }
        
        $crud = new grocery_CRUD();
        $crud->set_table('lookbook_image');
        $crud->set_subject('Image Look Book');
        $crud->required_fields('image');
        $crud->columns('lookbookCategoryId','imageTitle','imageDescription','image','active');
        $crud->display_as('sortOrder', 'Sort Order');
        $crud->display_as('lookbookCategoryId', 'Look Book Category');
        $crud->display_as('imageTitle', 'Image Title');
        $crud->display_as('imageDescription', 'Image Description');
        $crud->field_type('dateAdd', 'hidden');
        $crud->field_type('dateEdit', 'hidden');
        
        $crud->set_field_upload('image','assets/uploads/files');
        $crud->set_relation('active','aktivasi','active');
        $crud->set_relation('lookbookCategoryId', 'lookbook_category', 'lookbookTitle');
        
        $crud->set_field_upload('image', $this->mkdir_upload());
        
        $crud->unset_export();
        $crud->unset_print();
        
        $output = $crud->render();
        $this->lookbook_image_crud($output);
              
    }

    public function lookbook_image_crud($output = NULL){
        
        $this->load->view('lookbook_image.php',$output);
    }
    
    public function mkdir_upload(){
        
        if($this->input->post('lookbookCategoryId')){
            
            $path = base_url(). '../images/lookbook/' . $this->input->post('lookbookCategoryId');
            if(is_dir($path)){
                return $path;
            }
            else{
                $path = base_url() . '../images/lookbook/' . $this->input->post('lookbookCategoryId');
                if(mkdir($path,0777)){
                    return $path;
                }
                else{
                    log_message('error','Problem with creating folders. Path:' . $path);
                    exit;
                }
            }
        }
    }

I have a problem with loading upload not working