Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Image_lib.php resize with gd and dynamic_output on option will fail at PHP 5.4 #2132

Closed
keatliang2005 opened this Issue · 4 comments

4 participants

@keatliang2005

It work on previous version of PHP, but not PHP 5.4

i drill down the issue and suggest a fix

at /system/libraries/Image_lib.php line 1494 method name image_display_gd($resource)

change this

switch ($this->image_type)
{
    case 1  :   imagegif($resource);
        break;
    case 2  :   imagejpeg($resource, '', $this->quality); //this cause error, path not found in php 5.4
        break;
    case 3  :   imagepng($resource);
        break;
    default:    echo 'Unable to display the image';
        break;
}

to this

switch ($this->image_type)
{
    case 1  :   imagegif($resource);
        break;
    case 2  :   imagejpeg($resource, NULL, $this->quality); // fixed :)
        break;
    case 3  :   imagepng($resource);
        break;
    default:    echo 'Unable to display the image';
        break;
}

http://php.net/manual/en/function.imagejpeg.php
based on the PHP doc the default value is NULL

@TheDigitalOrchard

I've submitted this fix. It should be included once reviewed and accepted.

#2133

@keatliang2005
@narfbg
Owner

Just merged the fix.

@TheDigitalOrchard A quick note - mentioning the issue number in the PR title/description is better, as it would both a) create a reference link in the issue (e.g. here) and b) would make it easier to find through search. You've done the opposite here, which isn't that useful ... my .02 cents. Keep up the good work. :)

@narfbg narfbg closed this
@ryanscherler

This one really threw me for a loop today even after upgrading a client project from 2.1.2 to 2.1.4 (production) as their server was upgraded to PHP 5.4. I figured this fix would have been added into 2.1.4 since its 8 months old and closed. Turns out this still needs to be patched in the core lib on 2.1.4. REALLY wish this would make it into the current release of CI to prevent others from running into this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.