The imagecache module allows defining image presets such as Small or Large which creates thumbnails or versions of the original image that is being uploaded.
When using imagecache module together with insert module to upload an image and insert it to the wysiwyg, it is possible to insert to the wysiwyg an image with the pre-defined preset so that an img element is created with a source attribute such as:
<img src="/system/files/imagecache/Large/test_image_1.png" />
or
<img src="/system/files/imagecache/Small/test_image_1.png" />
When mimemail parses the HTML to grab all these links and turn them into attachments for the email notification it is counting on the file name to create the attachments (in this case: test_image_1.png) instead of the actual file URL.
This results in a bug if the same file is created in the same node's body with different image presets (and generally this introduces a bug where-as two files with the same file name (basename) will always just use the first occurrence only).
Comment | File | Size | Author |
---|---|---|---|
#16 | mimemail-1719256-16-d7.patch | 1.6 KB | sgabe |
#16 | mimemail-1719256-16-d6.patch | 1.67 KB | sgabe |
#14 | imemail_dont_handle_duplicate_filenames-1719256-12.patch | 911 bytes | lirantal |
#3 | mimemail_dont_handle_duplicate_filenames-1719256-2.patch | 893 bytes | lirantal |
#1 | mimemail_dont_handle_duplicate_filenames-1719256-1.patch | 639 bytes | lirantal |
Comments
Comment #1
lirantal CreditAttribution: lirantal commentedPatch for fixing this and relying on the filename for the static array as well as the md5.
Comment #2
sgabe CreditAttribution: sgabe commentedYou forgot to modify the
$filenames
array.But the most important is that we should only use $file if it is not the actual file content.
Comment #3
lirantal CreditAttribution: lirantal commentedYou're right, thanks.
Here's an updated version.
Regards,
Liran Tal.
Comment #4
sgabe CreditAttribution: sgabe commentedNow you forgot the most important part. :) We need to check if we are dealing with the file content, in that case we can't use $file and we have to use the $name.
Furthermore as a response to the name of your patch, we have to handle duplicate file names, see #358439: Images are only in the first message.
Comment #5
lirantal CreditAttribution: lirantal commentedThe patch handles the case of using duplicate file names by working on the full file path instead of just the basename.
Can you please explain what is the issue with checking file content?
Comment #6
sgabe CreditAttribution: sgabe commentedIf you take a better look at the code you will notice that sometimes
$file
will be the content:Comment #7
lirantal CreditAttribution: lirantal commentedJust to add, I've personally tested duplicate file names and it works just fine.
I've used 2 different images with the same file name (put in different folders locally), then created a new node, used the imagefield to upload and insert both of them into the node's body.
End result is that I get the 2 distinct images in the email notification as well as they both appear just fine in the node view.
Comment #8
sgabe CreditAttribution: sgabe commentedWe have posted at the same time, see #6.
Comment #9
lirantal CreditAttribution: lirantal commentedRight, but looking at the $new_file array it seems that anyway because if $content is passed, then $file = $content (earlier) then $new_file['file'] = $content which I think is somewhat bad, isn't it?
Anyway, I think you are referring to the problem where if $content is passed then it's being set in it's entirety into the $filesnames array, right?
Comment #10
sgabe CreditAttribution: sgabe commentedNo, mimemail_multipart_body takes care of the rest.
Yes!
Comment #11
lirantal CreditAttribution: lirantal commentedAlright then, how about instead of keeping a string'ed array value of the file name we simply keep a hash of it (md5 or crc32 should do)?
Comment #12
lirantal CreditAttribution: lirantal commentedActually, instead of another hash we can use $content_id. what do you think?
Comment #13
lirantal CreditAttribution: lirantal commented@sgabe ping?
Comment #14
lirantal CreditAttribution: lirantal commentedUpdated patch with use of $content_id for files array.
Can you please review and comment?
Comment #15
sgabe CreditAttribution: sgabe commentedJust a minor thing, since we do not use the actual file names, we should rename
$filenames
to$ids
which would be more accurate. I would also change$content_id
to just$id
.Comment #16
sgabe CreditAttribution: sgabe commentedRerolled patches for both branches. Let me know if this will work for you.
Comment #17
sgabe CreditAttribution: sgabe commentedCommitted to both branches!