When using mimemail with epublish, the default behavior of embedding all images makes for *really* large emails (like > 1 MB). This patch adds an administrative preference to link images instead of embedding them. It does this for png, gif, and jpg/jpeg extension urls that don't specify a protocol in their url.

This creates the behavior we are looking for, but doesn't change the default behavior for users. Please consider including.

Comments

sgabe’s picture

I miss the part why you can't use absolute links for the images in E-Publish? Why Mime Mail needs to create the correct links?

sdague’s picture

Because these are just picking up the images that are in nodes directly, that content being created by at least a dozen other people. I've also got the same issue with node_announce (which I own) and the print module (which I don't).

In all these cases the mailing modules could be made to preprocess the html before sending it to mimemail. But with 20 lines of code in mimemail it can instead do this at a site level for all the emails sent out, regardless of originator, which is what is desired from a site policy perspective.

sgabe’s picture

I think it is the responsibility of the user to provide content that fits for his needs. At first glance this option makes the absolute links and the embedding exclusive. If I enable the option I won't be able to send messages with embedded images anymore.

I think you just need to document this behavior so the users can decide what to do: if they want to send embedded images, they will use a relative path, otherwise they can use an absolute path. If they want to reduce the size of the message, they can use ImageCache (and not just manually resize the image in a WYSIWYG editor).

I will include module specific patches only if there is a very very good reason to do it. As I mentioned before I see no obstacle of using absolute links when creating the content that will be sent out via Mime Mail.

sdague’s picture

That may work fine for a site where the editors are all computer people, but it works very poorly for the non profits I support. They have no idea what kind of link an image has, it's added just via WYSIWYG and the IMCE bridge. They don't have the skills or understanding to go into the html and make those changes. And avoiding training farmers on html is the reason I chose Drupal in the first place. :)

It is exactly the point that for the 3 sites that I support we don't want any embedded images in any email. People complain loudly when their email is getting filled up with the large messages. This is true for all sending of email that we use, coming from multiple modules, as well as mimemail actions.

While this might not be your use case for sending email, I think it's a very common one. Making it site policy just like site policy of whether or not to specify css seems exactly right.

sgabe’s picture

I understand the problem, but this is not the right solution for it. You should search for another solution or try the Pathologic module, I think that's exactly what you need.

sgabe’s picture

Status: Needs review » Closed (won't fix)

You may also be interested in TinyMCE - URL conversion, furthermore I found Relative Path to Absolute URLs.

I am closing this issue.

sgabe’s picture

I have also found Absolute src.

sdague’s picture

Well, it's unfortunate that you won't fix it, because forcing all the urls to absolute in the code isn't an option. That means we can't have a test server with independent content because the full url is embedded. One of these sites already underwent a name change, and if I'd implemented this the way you said, it would have caused dozens of hours of rework.

Using absolute urls for local content just to work around behavior of mimemail seems really the wrong approach.

Guess I'll just keep maintaining my own patch to mimemail for this.

sgabe’s picture

I guess you didn't try the proposed solutions in my previous comment. You would not need to store the absolute paths, there are available and good solutions for your problem.

However if you want to do it this way, you can implement hook_mail_alter() in a custom module so you don't need to patch up Mime Mail every time when a new version comes out.

Embedding images is one of the essence of Mime Mail. If you only want to use HTML for your messages I think you can use HTML Mail. Some ways that can be a better choice.

sdague’s picture

My interest with mimemail is the fact that it correctly generates multipart/alternative email so there is both an html version and a text version. And I'd been using it for a while, so I was encouraged to add what I considered a useful feature.

I didn't expect this to be so contentious, as it was a relatively small amount of code, that was disabled by default, and just gave mimemail users additional option for usefulness.

I'll look into HTML Mail to see if that would do what I need.

sdague’s picture

It appears that HTML Mail only provides multipart/alternative if mimemail is installed, which means it would run into the same issue.

hook_mail_alter() approach doesn't seem to work in the test module I just wrote. I don't know if that hook is getting triggered when sending via mimemail. I'll do some more investigation at some point in the future here, because if I can actually made that change without a patch I need to keep rebasing, that would be great.

But the effort in keeping that patch up to date is actually pretty minor compared with completely rearchitecting things to use a different solution here (like correctly integrating and testing one of the approaches that changes the links in the content before they ever get to mimemail).

Sorry we couldn't see eye to eye here, as I really do believe this would be a feature of interest to a number of people.

sgabe’s picture

Status: Closed (won't fix) » Needs review

Lets leave this in active status and see what others think about this.

sgabe’s picture

@sdague: Please take a look at #1308630: Allow link modifications (e.g., to add campaign tracking) and share your thoughts with us. I think that's a good idea and can be a general solution for different use cases, including yours.

sgabe’s picture

Title: [PATCH] add a link images preference » Add preference to link images
Status: Needs review » Fixed
StatusFileSize
new1.79 KB
new1.84 KB

I have been thinking about this... Let's get this in. Committed to both branches.

sdague’s picture

sgabe thanks for looking into this again.

Status: Fixed » Closed (fixed)

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