Improved uploaded image verification
| Project: | Image Exact Sizes |
| Version: | 4.7.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | reviewed & tested by the community |
The attached patch makes two small corrections in image_exact. It may help the plethora of "image not found" and "division by 0 errors" currently posted.
The first change is making sure that an image was even uploaded before trying to resize. When uploading new images, the user can leave the image field blank (silly I know, but possible and even likely that such a situation would occur). So we need to make sure that image['_original'] has a value before trying to process it.
The second change simply accomplishes a more accurate check for the file's existence. In the situation presented above, image_exact still thought a file existed even though no image had ever been uploaded. Image_exact was being passed the file location ("/files") and saw that the directory existed. Rather than using the 'file_exists' function, use 'is_file' to make sure that the $source variable exists AND is a file.
The patch applies against the 4-7 branch. Thanks!
| Attachment | Size |
|---|---|
| improved_file_checking.patch | 1.04 KB |

#1
Looks like my patch conflicts if the patch for "Thumb is always selected" is also applied: http://drupal.org/node/75147. Here is a combo patch combining the above changes and the patch from that issue.
#2
I found a glitch in the "Thumb always selected" patch. This combo patch fixes that code to prevent image_exact from exact fitting every image size on upload.
#3
Sorry that last patch didn't make any changes from the first one. Here's the patch I meant to post.