diff --git a/cdn.module b/cdn.module index 4e19013..80437f5 100644 --- a/cdn.module +++ b/cdn.module @@ -67,6 +67,14 @@ function cdn_file_url_alter(&$path) { global $user; if ($status == CDN_ENABLED || ($status == CDN_TESTING && user_access(CDN_PERM_ACCESS_TESTING))) { + + // Convert a public streamwrapper path into its external path. + $scheme = file_uri_scheme($path); + if ($scheme == 'public') { + $wrapper = file_stream_wrapper_get_instance_by_scheme($scheme); + $path = $wrapper->getDirectoryPath() . '/' . drupal_encode_path(str_replace('\\', '/', (file_uri_target($path)))); + } + // If the current path is an absolute path, return immediately. $fragments = parse_url($path); if (isset($fragments['host'])) {