Option for Images to not being scaled up if smaller

Unless I haven't found the right combination of parameters for an image upload

$fields['image']['type']               = 'file';
$fields['image']['upload']             = true;
$fields['image']['multiple']           = false;
$fields['image']['multiline']          = false;
$fields['image']['overwrite']          = TRUE;
$fields['image']['display_overwrite']  = false;
$fields['image']['display_preview']    = true;
$fields['image']['create_thumb']       = FALSE;
$fields['image']['width']              = 1280;
$fields['image']['height']             = 1280;
$fields['image']['maintain_ratio']     = TRUE;
$fields['image']['resize_and_crop']    = false;
$fields['image']['resize_method']      = 'maintain_ratio';
$fields['image']['master_dim']         = 'auto';
$fields['image']['file_name']          = '{slug}'; // '{id}-{slug}' isn't working?

I end up with small images being blown up to 1280px, which is kind of weird, because it needs more space and quality gets worse.

Right now, I'm overwriting Fuel_assets::upload - but I don't like to keep track of this complex function if something changes later. So I wish there was a parameter to tell fuel "only resize if orig image if larger than $fields['image']['width']

Here is my fuel\application\libraries\MY_Fuel_assets.php


// in Events_model.php I do this:
//$CI->load->library('MY_Fuel_assets, array(), 'fuel_assets');

require_once(FUEL_PATH . 'libraries/Fuel_assets.php');

class MY_Fuel_assets extends Fuel_assets {

    public function upload($params = array())

            // ... all the code of the original Fuel_assets::upload() method


                // check for if they want just a resize or a resize AND crop
                if (!empty($params['resize_and_crop']) OR (!empty($params['resize_method']) AND $params['resize_method'] == 'resize_and_crop'))
                    $resize = $this->CI->image_lib->resize_and_crop();
                    $resize = true;
                    // resize only if image is wider than $params['width']
                    if ($this->CI->image_lib->orig_width > $params['width']) {
                        $resize = $this->CI->image_lib->resize();


                if (!$resize)


Could this become an option in a future version?


  • Sounds like there would need to be a "do_not_upsize" type parameter that could be used for such situations. If you can submit a pull request on the develop branch with the suggestion, I can review it. I could foresee changes to the Fuel_assets::upload method (like you've displayed) as well as the Fuel_custom_fields::file and Fuel_custom_fields::asset field type methods (do a search for something like "resize_and_crop" because it would live alongside that most likely)

  • edited August 2019

    pull request sent. I hope it works out.

  • Thanks... it looked good and I merged it in.

Sign In or Register to comment.