diff --git a/imagecache.module b/imagecache.module index 2e5de2c..fbf0eaa 100644 --- a/imagecache.module +++ b/imagecache.module @@ -343,8 +343,21 @@ function imagecache_create_url($presetname, $filepath, $bypass_browser_cache = F $args = array('absolute' => $absolute, 'query' => empty($bypass_browser_cache) ? NULL : time()); switch (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC)) { case FILE_DOWNLOADS_PUBLIC: - $base = $absolute ? $GLOBALS['base_url'] .'/' : ''; - return url($base . file_directory_path() ."/imagecache/$presetname/$path", $args); + // Build the path including the preset name, and save a copy + $path = file_directory_path() .'/imagecache/'. $presetname .'/'. $path; + $old_path = path; + drupal_alter('file_url', $path); + + // If hook_file_url_alter() did not change the output, then we need to add + // the base URL. If it did, we can presume the path needs no modification. + if ($path == $old_path){ + $path = $GLOBALS['base_url'] . '/' . $path; + } + + // Even though our path here may have been altered, and point to a CDN or + // something, we still want to use url() so that bypass_browser_cache works + return url($path, $args); + case FILE_DOWNLOADS_PRIVATE: return url("system/files/imagecache/$presetname/$path", $args); }