From dbada5dbbf361f399f9a54d698a75041495766ff Mon Sep 17 00:00:00 2001 From: Romina Date: Thu, 13 Aug 2020 11:10:50 -0300 Subject: [PATCH] fix: use add CDN_PREFIX environment variable to allow targetting folders in media storage --- src/Core/Tool/Uploader.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Core/Tool/Uploader.php b/src/Core/Tool/Uploader.php index 8293c32067..8d2d9f16e8 100644 --- a/src/Core/Tool/Uploader.php +++ b/src/Core/Tool/Uploader.php @@ -48,16 +48,16 @@ public function upload(UploadData $file, $filename = null) // to be made lowercase. Also replace possibly invalid characters in filename $filename = strtolower(preg_replace('/[^\pL\pN\-\_\s\.]+/u', '', $filename)); - // Add the first and second letters of filename to the directory path // to help segment the files, producing a more reasonable amount of // files per directory, eg: abc-myfile.png -> a/b/abc-myfile.png - $filepath = implode('/', [ + $filepath = implode('/', array_filter([ + getenv('CDN_PREFIX'), $this->multisite->getSite()->getCdnPrefix(), $filename[0], $filename[1], $filename, - ]); + ])); // Remove any leading slashes on the filename, path is always relative. $filepath = ltrim($filepath, '/');