Welcome Guest, Not a member yet? Register   Sign In
[Solved] Codeigniter Image_lib Not resizeing all images
#1

(This post was last modified: 08-24-2017, 01:58 AM by wolfgang1983.)

I have this code below where I am trying to resize multiple images in foreach loop it only resizes some and not all at once.

Question how can I make sure it can resize all images at once.

PHP Code:
public function index() {

// Get directories
 
   $directories glob($directory '/' $filter_name '*'GLOB_ONLYDIR);

 
   if (!$directories) {
 
       $directories = array();
 
   }

 
      // Get files
 
   $files glob($directory '/' $filter_name '*.{jpg,jpeg,png,gif,JPG,JPEG,PNG,GIF}'GLOB_BRACE);

 
   if (!$files) {
 
       $files = array();
 
   }

 
   // Merge directories and files
 
   $images array_merge($directories$files);
 
   
    foreach 
($images as $key => $image) {

 
       if ($key $segment && $key >= $segment $per_page) {

 
           name str_split(basename($image), 18);

 
           if (is_file($image)) {

 
               $data['images'][] = array(
 
                       'thumb' => $this->resize($image),
 
                       'name' => implode(' '$name),
 
                       'type' => 'image',
 
                       'test' => '',
 
                       'path' => utf8_substr($imageutf8_strlen(FCPATH 'image/')),
 
                       'href' => base_url() . 'image/' utf8_substr($imageutf8_strlen(FCPATH 'image/'))
 
               );
 
           }
 
          }
 
   }    
}

public function 
resize($filename) {
 
   $this->load->library('image_lib');

 
   $width 100;
 
   $height 100;

 
   $old_filename substr($filenamestrlen(FCPATH 'image/'));

 
   $extension pathinfo($old_filenamePATHINFO_EXTENSION);

 
   $new_image substr($old_filename0strrpos($old_filename'.')) . '-' $width 'x' $height '.' $extension;

 
   $config['image_library'] = 'gd2';
 
   $config['source_image'] = $filename;
 
   $config['create_thumb'] = FALSE;
 
   $config['maintain_ratio'] = FALSE;
 
   $config['width'] = $width;
 
   $config['height'] = $height;
 
   $config['new_image'] = FCPATH 'image/cache/' $new_image;
 
               
    $this
->image_lib->clear();
 
   $this->image_lib->initialize($config);
 
   $this->image_lib->resize();
 
       
    return base_url
('image/cache/') . $new_image;



Attached Files
.php   Filemanager.php (Size: 13.49 KB / Downloads: 94)
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply


Messages In This Thread
[Solved] Codeigniter Image_lib Not resizeing all images - by wolfgang1983 - 08-23-2017, 03:50 AM



Theme © iAndrew 2016 - Forum software by © MyBB