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.
Comment | File | Size | Author |
---|---|---|---|
#3 | filefield_resize_image_cache.patch | 2.1 KB | quicksketch |
filefield-imageapi-filesize.patch | 919 bytes | folkertdv |
Comments
Comment #1
quicksketchThanks! 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.
Comment #2
folkertdv CreditAttribution: folkertdv commentedSwift 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.
Comment #3
quicksketchNow 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. :)