Hi, as stated in #1281530: Keep id of message parts from $structure I've been working on a simple image parser.
Actually it does that:
- find img tags
- save images to local dirs
- rewrite img tag src attribute to saved local image (or remove the tag)
- make avaiable the images to field mapping
Some tought:
» security: I've tried to clean out the image content (from eg embed php code) by forcing a scale with gd. It should be done throught the core image api.
» in mailhandler/plugins/MailhandlerCommandsFiles.class.php line 34
- unset($message['mimeparts']);
+ //unset($message['mimeparts']);
or the mail parts won't be available to the html command.
A nice thing could be integrate or let attachments command skip images to avoid have them both in attachments and images fields
I wait for any usage reviews!
Thanks,
Luca
| Comment | File | Size | Author |
|---|---|---|---|
| MailhandlerCommandsHtmlImages.zip | 3.12 KB | muka |
Comments
Comment #0.0
muka commentedcorrected html tags which mess the body
Comment #1
danepowell commentedYou've obviously put in a lot of work on this, thanks for contributing. It does need some work like you said. On the Mailhandler side, I see that there are some configuration options but no way to set them. I've grappled in the past with how to let command parsers store configuration data. The problem is that Feeds doesn't really seem to allow for this- I've touched on this issue in the Feeds queue at #1145116: Feeds Multi Parser but perhaps I need to open a dedicated issue or focus a little more on it.
Comment #2
danepowell commentedI've committed a fix that might help you - see #1314788: Allow commands parsers to store config in db
Comment #3
danepowell commentedComment #4
danepowell commentedI wasn't too familiar with the standards for embedding images in emails, so I did some reading... it seems from http://www.ietf.org/rfc/rfc2111.txt that just about any file type can be attached to an email and referenced inline using the 'cid' tag. So I don't think we should limit this to images.
I think the best way to handle this is to grab the attachments, and if an attachment has a matching Content-ID, do a preg_replace on the email body to replace
cid:[content-id]with the new link to the file.Comment #5
danepowell commentedI have this almost working in a local development branch. The only problem is that at the point where Mailhandler hands off the relevant mapping sources (message body and attachments) to feeds, it can only know the temporary URIs of attached files. I think Feeds needs to take responsibility at that point and update temporary URIs in the node body before saving the node. See #1475596: Rewrite file URIs in node body on message import
Comment #6
muka commentedHi,
I would like to help in test and (where I can) with code, can you post a dev snapshot somewhere to work on it ?
Thanks, Luca
Comment #7
danepowell commentedI pushed the development branch to drupal.org: 7.x-2.x-1314128 . Any help is appreciated, but like I said the holdup is in Feeds now.
Comment #8
muka commentedFor sure if Feeds could handle this would be much better.
But couldn't be handled with a content filter or on hook_node_view() ?
Eg. adding a specific prefix like
Comment #9
danepowell commentedI've committed a fix to 7.x-2.x: http://drupalcode.org/project/mailhandler.git/commit/f889954
Note that this requires the patch at #1475596: Rewrite file URIs in node body on message import.
Comment #10
rsbecker commentedIs there any progress on this? When inline images arrive via mailhandler from Thunderbird here is what the tag in the node looks like:
The image is downloaded and saved in directory according to parameters set by filefield_path, and it is available on the node as a cck image field. So Drupal knows where the file is. How can we get the inline image tag changed from the mimepart to the path?
Comment #11
Yuri commentedFor D7 I have applied the modifications in patch mentioned in #9 https://drupal.org/node/1475596
But the D7 dev version of Mailhandler still does not show the correct URLS for images in the body fields.
Did any of you actually got this working in D7?
Comment #12
Yuri commentedOk forgot to flush cash ..and now it works! Inline images (as well as attached images) are showing.
However, the patch mentioned in #9 https://drupal.org/files/feeds-1475596-2.patch needs to be updated because the line number has changed (around line 121).
Thanks!
Comment #13
coreycondardo commentedI've patched Feeds and Installed the dev version of mail handler however when I email with an inline image the img src in the full HTML wysiwyg body field is public://mailhandler_temp/imagename.png. If I change it to sites/default/files/mailhandler_temp/drupal.png it works, but with public:// it doesn't work. Any idea what I have to do to get that working?
Thanks!
Corey
Comment #14
danepowell commentedAs long as the status on this is 'to be ported', please keep the version at 6.x
Comment #15
jetwodru commentedHi,
I tested the 7.x.29, found that inline images as well as attachment are still not supported, is this in progress ? thanks.
Comment #16
danepowell commentedAttachments have always been supported. Inline images are supported in 7.x-2.9, but you'll need the patch in #9. Please open a separate issue if you're having problems- let's keep this thread open only for development of a 6.x patch.
Comment #16.0
danepowell commentedcorrected issues ref
Comment #17
leducdubleuet commentedInline images are still not working for D7 even with version 7.x.29 and the patch for Feeds in Comment #9.
So I have opened another issue for D7 with a patch : https://drupal.org/node/2228401