CodeIgniter Forums

Full Version: CI_Image_lib::image_save_gd() -- always returns TRUE regardless
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]coolfactor[/eluser]
This function always returns TRUE whether or not it was able to save the image. Since the internal calls to imagegif(), imagejpg() and imagepng() are silenced in this function, no error is displayed. Then the function defaults to returning TRUE at the end of its call, so the function that called it has no idea that it wasn't able to do its job.

How to reproduce:
Attempt to resize an image to a non-existent folder. The resize() operation will pass with flying colors, but no resized image will be found.

Possible solutions:

1. Validate that the destination path is writeable before calling this function.
or
2. Return FALSE from this function and handle that in the calling code.

Note: this is not a function called directly from outside of the Image_lib. It's called internally, so the only way for a user of the library to fix it would be subclass the Image_lib class and put the fix in the subclass. The permanent fix needs to be part of a CodeIgniter update.