Index: imagecache.module =================================================================== --- imagecache.module (revision 4) +++ imagecache.module (revision 71) @@ -307,18 +307,21 @@ * @param $bypass_browser_cache * A Boolean indicating that the URL for the image should be distinct so that * the visitors browser will not be able to use a previously cached version. - * This is + * @param $absolute + * Whether to force the returned URL to be an absolute link (beginning with http:). + * Default TRUE for backward compatibility */ -function imagecache_create_url($presetname, $filepath, $bypass_browser_cache = FALSE) { +function imagecache_create_url($presetname, $filepath, $bypass_browser_cache = FALSE, $absolute = TRUE) { $path = _imagecache_strip_file_directory($filepath); if (module_exists('transliteration')) { $path = transliteration_get($path); } - $args = array('absolute' => TRUE, 'query' => empty($bypass_browser_cache) ? NULL : time()); + $args = array('absolute' => $absolute, 'query' => empty($bypass_browser_cache) ? NULL : time()); switch (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC)) { case FILE_DOWNLOADS_PUBLIC: - return url($GLOBALS['base_url'] . '/' . file_directory_path() .'/imagecache/'. $presetname .'/'. $path, $args); + $base = $absolute ? $GLOBALS['base_url'] . '/' : ''; + return url($base. file_directory_path() .'/imagecache/'. $presetname .'/'. $path, $args); case FILE_DOWNLOADS_PRIVATE: return url('system/files/imagecache/'. $presetname .'/'. $path, $args); } @@ -820,10 +823,13 @@ * @param $getsize * If set to TRUE, the image's dimension are fetched and added as width/height * attributes. + * @param $absolute + * If set to TRUE, the image's path will be absolute (beginning with http:) + * Default TRUE for backward compatibility * @return * HTML img element string. */ -function theme_imagecache($presetname, $path, $alt = '', $title = '', $attributes = NULL, $getsize = TRUE) { +function theme_imagecache($presetname, $path, $alt = '', $title = '', $attributes = NULL, $getsize = TRUE, $absolute = TRUE) { // Check is_null() so people can intentionally pass an empty array of // to override the defaults completely. if (is_null($attributes)) { @@ -835,7 +841,7 @@ } $attributes = drupal_attributes($attributes); - $imagecache_url = imagecache_create_url($presetname, $path); + $imagecache_url = imagecache_create_url($presetname, $path, FALSE, $absolute); return ''. check_plain($alt) .''; }