/**
* Return a URL that points to the location of a derivative of the
* original image at @p $path, transformed with the given @p $preset.
+ *
+ * Special care is taken to make this work with the possible combinations of
+ * Clean URLs and public/private downloads. For example, when Clean URLs are not
+ * available an URL with query should be returned, like
+ * http://example.com/?q=files/imagecache/foo.jpg, so that imagecache is able
+ * intercept the request for this file.
+ *
+ * This code is very similar to the Drupal core function file_create_url(), but
+ * handles the case of Clean URLs and public downloads differently however.
*/
function imagecache_create_url($presetname, $path) {
$path = _imagecache_strip_file_directory($path);
- return file_create_url(file_directory_path() .'/imagecache/'. $presetname .'/'. $path);
+ switch (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC)) {
+ case FILE_DOWNLOADS_PUBLIC:
+ return url(file_directory_path() .'/imagecache/'. $presetname .'/'. $path, NULL, NULL, TRUE);
+ case FILE_DOWNLOADS_PRIVATE:
+ return url('system/files/imagecache/'. $presetname .'/'. $path, NULL, NULL, TRUE);
+ }
}
/**
imagecache_preset_flush($preset);
imagecache_presets(true);
}
-
-