When using imagecache and insert modules and variable "insert_absolute_paths" is set to FALSE:

  1. An incorrect file path is returned when working with private file system config
  2. Imagecache presets do not get created

This happens in includes/imagecache.inc

function template_preprocess_imagecache_insert_image(&$vars) {
}

Which behaves differently depending on whether "insert_absolute_paths" is TRUE or FALSE and causes the issue.

The fix is simple - when handling the case where "insert_absolute_paths" variable is set to FALSE simply use the same imagecache_create_url() function with a FALSE argument set for the $absolute default variable, such as:

$vars['url'] = imagecache_create_url($vars['preset_name'], $vars['item']['filepath'], FALSE, FALSE);

Regards,
Liran Tal.

Comments

lirantal’s picture

Status: Needs work » Needs review
StatusFileSize
new672 bytes

Attached is the patch to make this happen.

quicksketch’s picture

Priority: Critical » Normal

Thanks, good suggestion! I'm reviewing this now. Not a critical issue though (http://drupal.org/node/45111).

quicksketch’s picture

Status: Needs review » Fixed
StatusFileSize
new872 bytes

Thanks, the patch worked great, but we can simplify it down further and make it all one line. Looks like the $absolute parameter was added only in more recent versions of ImageCache. Nice that it's there, it significantly simplifies the situation. Committed this patch.

lirantal’s picture

Sure, if we're at perfecting the code I'll also add a (bool) casting just to make sure.

quicksketch’s picture

Sounds good, I've added your extra (bool) check too. Though strict checking isn't common in Drupal contrib, we should be explicit when calling another module's functions. Thanks!

Status: Fixed » Closed (fixed)

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