Codeigniter image resize?

前端 未结 6 1424
故里飘歌
故里飘歌 2020-11-28 14:43

I have problem with image class in CI?

This is example

On controller:

$this->load->library( array(\'image_lib\') );

O

6条回答
  •  情歌与酒
    2020-11-28 15:14

    You shouldn't load image_lib in foreach. Try to use code below

    $this->load->library('image_lib');
    foreach($results as $row) {
        $config['image_library'] = 'gd2';
        $config['source_image'] = '/img/proizvodi/'.$row->proizvodid.'.jpg';
        $config['create_thumb'] = TRUE;
        $config['maintain_ratio'] = TRUE;
        $config['width']     = 75;
        $config['height']   = 50;
    
        $this->image_lib->clear();
        $this->image_lib->initialize($config);
        $this->image_lib->resize();
    }
    

    If it wont work - check the upload folder permissions.

提交回复
热议问题