From 6dc5b5449d6c52b433e6b712786c2e49778a363f Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sun, 12 Jul 2009 08:36:35 +0000 Subject: - Patch #491456 by quicksketch, drewish, et al: image effects and actions. --- includes/file.inc | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'includes') 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); @@ -1500,6 +1498,23 @@ function file_directory_path() { return variable_get('file_directory_path', conf_path() . '/files'); } +/** + * 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. * -- cgit v1.2.3