summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--imagecache.module22
-rw-r--r--imagecache_ui.pages.inc2
2 files changed, 19 insertions, 5 deletions
diff --git a/imagecache.module b/imagecache.module
index ec87b48..909ee08 100644
--- a/imagecache.module
+++ b/imagecache.module
@@ -288,7 +288,7 @@ function imagecache_action_definition($action) {
/**
* Return a URL that points to the location of a derivative of the
- * original image at @p $path, transformed with the given @p $preset.
+ * original image transformed with the given 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
@@ -298,10 +298,24 @@ function imagecache_action_definition($action) {
*
* 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.
+ *
+ * @param $presetname
+ * @param $filepath
+ * String specifying the path to the image file.
+ * @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
*/
-function imagecache_create_url($presetname, $path) {
- $path = _imagecache_strip_file_directory($path);
- return file_create_url(file_directory_path() .'/imagecache/'. $presetname .'/'. $path);
+function imagecache_create_url($presetname, $filepath, $bypass_browser_cache = FALSE) {
+ $path = _imagecache_strip_file_directory($filepath);
+ $args = array('absolute' => TRUE, 'query' => $bypass_browser_cache ? time() : $bypass_browser_cache);
+ switch (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC)) {
+ case FILE_DOWNLOADS_PUBLIC:
+ return url($GLOBALS['base_url'] . '/' . file_directory_path() .'/imagecache/'. $presetname .'/'. $path, $args);
+ case FILE_DOWNLOADS_PRIVATE:
+ return url('system/files/imagecache/'. $presetname .'/'. $path, $args);
+ }
}
/**
diff --git a/imagecache_ui.pages.inc b/imagecache_ui.pages.inc
index 3e5e664..053377e 100644
--- a/imagecache_ui.pages.inc
+++ b/imagecache_ui.pages.inc
@@ -334,7 +334,7 @@ function imagecache_ui_preset_form($form_state, $preset = array()) {
file_copy($preview_path, 'imagecache_sample.png');
}
imagecache_image_flush($preview_path);
- $imagecache_path = imagecache_create_url($preset['presetname'], $preview_path) .'?'. time();
+ $imagecache_path = imagecache_create_url($preset['presetname'], $preview_path, TRUE);
$form['preview'] = array(
'#type' => 'item',
'#title' => t('Preview'),