Welcome Guest, Not a member yet? Register   Sign In
Resizing Images need help
#1

[eluser]Leftfield[/eluser]
Hello gooros!
I need to resize uploaded images. I have Controller and View, but images not resized ...

Controller:
Code:
/*
        * Screenshots
        */

        $data['images'] = directory_map('images/upload'); //Эта функция считывает содержимое директории,
        //путь к которой указан в первом параметре, и строит массив с содержимым директории
        $config['image_library'] = 'gd2';
        $config['source_image'] = '/images/upload/'.$data['images'];
        $config['create_thumb'] = TRUE;
        $config['maintain_ratio'] = TRUE;
        $config['width'] = 75;
        $config['height'] = 50;
        
        $this->load->library('image_lib', $config);
        
        $this->image_lib->resize();

        /*
        *  Screenshots
        */
        $this->load->view('default/view_screenshots', $data);

View:
Code:
<? foreach ($images as $value): ?>
   <a href="#"><img src="/images/upload/&lt;?= $value ?&gt;" alt="" border="2">
   <br/><b>Name:&nbsp;&lt;?= $value ?&gt;</b>
   &lt;? endforeach ;?&gt;
#2

[eluser]pickupman[/eluser]
Wouldn't this be from calling the original images? The library works one file at a time, so you can't pass an array of file names to the library. You have $data['images'] above the thumbs. You need to call the array of images that contain your_filename_thumb.jpg as your source instead. Use directory_map() function to get array of files. Loop through the array and use preg_match() to find your thumbnails, and save to a "thumbnail" array. Then loop the "thumbnail" array in your view.

The other options to create thumbnail method, and stream the resized images on the fly like phpThumb.




Theme © iAndrew 2016 - Forum software by © MyBB