Welcome Guest, Not a member yet? Register   Sign In
Code Question
#1

Hello, I have a model function that I have been working on every thing seems to be working fine

I would like to no should I make a if statement for my return base_url() at the bottom of page.

If so what would you recommend?

PHP Code:
<?php

class Model_image_resize extends CI_Model {

    public function 
__construct() {
        
parent::__construct();
        
$this->load->library('image_lib');
    }

    public function 
resize($image$width$height) {
        
$old_image_path FCPATH 'images/';
        
$new_image_path FCPATH 'images/cache/';
        
$old_image  $old_image_path $image;
        
$img '';
        
$extension  pathinfo($old_imagePATHINFO_EXTENSION);
        
$old_image_convert substr($image0 strrpos($image'.')) . '-' $width 'x' $height '.' $extension;
        
$new_image $new_image_path $old_image_convert;

        if (
file_exists($old_image)) {

         
  $config['image_library'] = 'gd2';
         
  $config['source_image'] = $old_image;
         
  $config['create_thumb'] = FALSE;
         
  $config['maintain_ratio'] = FALSE;
         
  $config['width'] = $width;
         
  $config['height'] = $height;
         
  $config['new_image'] = $new_image;

         
  $this->image_lib->clear();
     
             $this->image_lib->initialize($config);
     
             $this->image_lib->resize();

     
             $files explode($new_image_path$new_image);

     
             foreach ($files as $file) {
     
               $img  $file;
     
             }
     
              
           
} else {

 
              @unlink($new_image);

 
          }
 
          
           
return base_url('images/cache') . '/' $img;
    }



Attached Files
.php   Model_image_resize.php (Size: 1.26 KB / Downloads: 41)
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
Code Question - by wolfgang1983 - 06-20-2016, 12:24 AM
RE: Code Question - by PaulD - 06-20-2016, 09:01 AM



Theme © iAndrew 2016 - Forum software by © MyBB