When an image is uploaded and attached to a node in one step (using the "Upload image" box), the Image module copies the image file from the Drupal temp directory to the files/images/temp directory, then deletes the source. But it also stores the pathname of the source file in $file->filepath, and later tries to use it to get the image's dimensions. The result is a divide-by-zero error when it tries to divide width by height, and both are null because they are taken from elements of an array which is itself null.
Another consequence of this problem is that Image is unable to create derivative images from the uploaded file.
I'm reporting this as an Image Attach bug because it presents itself there, but the bug really is in Image.
I have a patch that corrects the immediate problem, but I have not been able to get the patch utility to work so that I can submit it in the customary form. For now, the best I can do is to attach the two affected files. The patched lines of code are marked by the signature "// JHS".
This patch works by updating $file->filepath to point to the image file in files/images/temp when the one in the Drupal temp directory is deleted. It has been tested only to a limited extent. It has not been tested in the case where an existing image (rather than an uploaded image) is being attached to a node.
| Comment | File | Size | Author |
|---|---|---|---|
| 080625 JHS Image patch.zip | 13.37 KB | orthoducks |
Comments
Comment #1
orthoducks commentedI revisited this and discovered that the problem is more subtle than I thought. The corrected files I uploaded do not completely fix it. I'm going to fix it when I can, but I won't have a chance to try until late next week (around 12 July). Anyone who may consider taking action on my report above, please stand by, and I hope I can save you some work.
Comment #2
sunThis will be covered in #81102: Attach Multiple Images with image_attach using Drupal upload mechanism