Since imagecache images are only generated when they are accessed via http, it can happen that imagecache images are referred to in a mimemail message, but the image in question has not yet been generated.

In this situation, mimemail will not only fail to embed the image, but tacks on http:// to the beginning of the relative URL, making it completely unusable.

The following patch adds support for not-yet-rendered imagecache images. If imagecache images are encountered in a message, it will check to see if they have been properly rendered to file, and if not will instruct imagecache to render them before continuing with the embed.

Comments

sgabe’s picture

StatusFileSize
new1.61 KB

I am attaching a revised patch of yours.

sgabe’s picture

Title: Imagecache images sometimes not correctly embedded » Generate not existing ImageCache images before embedding
Version: 6.x-1.x-dev » 7.x-1.x-dev
Status: Needs review » Patch (to be ported)
StatusFileSize
new1.82 KB

Seems to work for me. Committed to D6, needs to be ported to D7.

sgabe’s picture

adamps’s picture

Title: Generate not existing ImageCache images before embedding » Force generation of Image Styles

Updated title to closer match D7 terminology (D6 is all fixed now).

For D7, one possible workaround is using the image_resize_filter module. It has code to generate the image styles. Set the variable mimemail_format - in GUI admin/config/system/mimemail/ "E-mail format" to a text format that includes "Image resize filter".

This module also contains some helpful code towards fixing this issue. Search for the call to image_style_create_derivative around line 353.

Ives’s picture

For a quick fix, I used following code in my template:

    $derivative_uri = image_style_path('my-display-style', $image['uri']);
    $style = image_style_load('my-display-style');
    image_style_create_derivative($style, $image['uri'], $derivative_uri);

See http://drupal.stackexchange.com/questions/54581/force-image-style-genera...

chrbak’s picture

This problem continues to the version for drupal 8 too.