Hello,

After experiencing some weird behavior with images that kept loading for a long time and disappeared after loading was complete, I started digging through all relevant code.
Fifteen minutes later I was able to track the bug down to this module.

When defining a CCK field for uploading images, you can specify a maximum resolution. The function filefield_validate_image_resolution checks for this and resizes the image if necessary. After resizing the image it updates the filesize in the passed file object.

The problem: If you have the ImageAPI module enabled, its resizing function gets called but the filesize is not updated.

I've attached a quick fix patch that I'm using currently, though I'm sure a more elegant patch can be written.

Comments

Version:6.x-3.x-dev» 6.x-3.7
Status:Active» Needs review

Thanks! I think there may be a faster approach than calling image_get_info(), if we're just interested in file size we can use filesize() I believe. Either way thanks for the patch, I think that I should be able to fix it up from here the next time I'm working on FileField.

Swift response, excellent. The use of filesize() is indeed a simpler approach, I just copied the filesize-part from a few lines ahead.
The patch above is merely a temporary fix for people facing this issue until it has been properly fixed.

Status:Needs review» Fixed
StatusFileSize
new2.1 KB

Now that I've reviewed this patch I totally see where you were coming from. Rather than copy/paste the exact same code I set a variable and did a separate check that applies no matter which system resized the image. Thanks for the nice catch on this one. :)

Status:Fixed» Closed (fixed)
Issue tags:-imageapi, -resize, -filesize, -loading, -corrupt

Automatically closed -- issue fixed for 2 weeks with no activity.