Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Last commit (WPML fix) broke the result when there is no image #91

Open
rubenbristian opened this issue Aug 17, 2016 · 4 comments
Open

Comments

@rubenbristian
Copy link

Hi

In last commit you've removed the $result variable, which actually made sure that you get an image if the resize fails.. The fail can be caused by multiple reasons, even if the image exists. So now, if there is no resize, you get an empty string. This is obvious an error, which previously worked well..

Please return the $result variable.. Instead of a simple return it should be like this:

$result = $aq_resize->process( $url, $width, $height, $crop, $single, $upscale ); return $result !== false ? $result : $url;

Actually, this still breaks if the user requests an array. Because if he does, most probably he'll check for something like $resized_img[0], which will return the first letter of the string. So, a better solution would be something like this for the last line:

return $result !== false ? $result : ( $single ? $url : array( $url, $width, $height ) );

@JonatanJJ
Copy link

I would not consider your solution adequate in the case of $upscale being true.
Also in case of $single being false the $width and $height returned in your example would not match the returned images dimensions, not sure if this is desired?

image_resize_dimensions will return false if $crop is false and the original image dimensions are less than those requested, no matter the value of $upscale.
In this case aq_resize currently returns an empty result, and might even throw a PHP warning(?).

Aq_resize should either return an upscaled image or the original image.

@benedikt-buchert
Copy link

Also a little more helpful error would be great. Just had an image that was not resizing because it was simply to small. Took me a while to understand that the image was simply to small.

@arawls-csu
Copy link

@Jontis00 How do we resolve this error? I am experiencing this error currently.

@JonatanJJ
Copy link

@arawls-csu Have you tried version 1.2.2? Sounds like e00a662 tried to solve this issue, but I have not tested it myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants