Here's a pretty typical scenario:

  • "Include site style sheets" is enabled (by default).
  • "Optimize CSS files" is turned on (a best practice for optimization).

In this scenario, Mime Mail will never include the CSS contained in the optimized CSS files. The reason is that Drupal uses file_create_path() to embed the absolute URL to the CSS file, and template_preprocess_mimemail_message() will only scrape stylesheets which start with the base path ("/" in most installations).

The attached patch adjusts the regex to match stylesheets which start with the full url or simply the base path. For example, if the base url was "http://example.com" and the base path was "/", it will match the following:

/sites/default/themes/mytheme/styles.css
http://example.com/sites/default/files/css/css_a8eb6397fb52e26ce134105966d423fb.css

Comments

joelstein’s picture

Title: Absolute site styles not included when compressing CSS » Absolute site stylesheets not included in template_preprocess_mimemail_message()

Sorry, this is not just when compressing. Adjusting the title.

sgabe’s picture

I can't reproduce. As I see drupal_get_css() uses base_path() as well.

$output .= '<link type="text/css" rel="stylesheet" media="' . $media . '" href="' . base_path() . $preprocess_file . '" />' . "\n";
sgabe’s picture

Title: Absolute site stylesheets not included in template_preprocess_mimemail_message() » Absolute site stylesheets not included
Priority: Major » Normal
Status: Needs review » Fixed
StatusFileSize
new653 bytes

Seems to be valid, patch committed, thanks!

Status: Fixed » Closed (fixed)

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