Improved uploaded image verification

quicksketch - August 12, 2006 - 07:04
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
Description

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!

AttachmentSize
improved_file_checking.patch1.04 KB

#1

quicksketch - August 12, 2006 - 07:17

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.

AttachmentSize
check_and_thumb.patch 3.48 KB

#2

quicksketch - August 12, 2006 - 08:40

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.

AttachmentSize
check_and_thumb2.patch 3.4 KB

#3

quicksketch - August 12, 2006 - 08:52

Sorry that last patch didn't make any changes from the first one. Here's the patch I meant to post.

AttachmentSize
check_and_thumb3.patch 3.3 KB
 
 

Drupal is a registered trademark of Dries Buytaert.