diff options
author | Dries Buytaert <dries@buytaert.net> | 2009-07-12 08:36:35 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2009-07-12 08:36:35 +0000 |
commit | 6dc5b5449d6c52b433e6b712786c2e49778a363f (patch) | |
tree | 66e4926fa3dcc0a33f46f4145ca5b72bf7458943 /includes | |
parent | 065fa60551edddc27a30d04cecb58b30b7ac8e3c (diff) | |
download | brdo-6dc5b5449d6c52b433e6b712786c2e49778a363f.tar.gz brdo-6dc5b5449d6c52b433e6b712786c2e49778a363f.tar.bz2 |
- Patch #491456 by quicksketch, drewish, et al: image effects and actions.
Diffstat (limited to 'includes')
-rw-r--r-- | includes/file.inc | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/includes/file.inc b/includes/file.inc index 73d513703..08bbbfdd5 100644 --- a/includes/file.inc +++ b/includes/file.inc @@ -85,9 +85,7 @@ define('FILE_STATUS_PERMANENT', 1); function file_create_url($path) { // Strip file_directory_path from $path. We only include relative paths in // URLs. - if (strpos($path, file_directory_path() . '/') === 0) { - $path = trim(substr($path, strlen(file_directory_path())), '\\/'); - } + $path = file_directory_strip($path); switch (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC)) { case FILE_DOWNLOADS_PUBLIC: return $GLOBALS['base_url'] . '/' . file_directory_path() . '/' . str_replace('\\', '/', $path); @@ -1501,6 +1499,23 @@ function file_directory_path() { } /** + * Remove a possible leading file directory path from the given path. + * + * @param $path + * Path to a file that may be in Drupal's files directory. + * @return + * String with Drupal's files directory removed from it. + */ +function file_directory_strip($path) { + // Strip file_directory_path from $path. We only include relative paths in + // URLs. + if (strpos($path, file_directory_path() . '/') === 0) { + $path = trim(substr($path, strlen(file_directory_path())), '\\/'); + } + return $path; +} + +/** * Determine the maximum file upload size by querying the PHP settings. * * @return |