Skip to content

Commit

Permalink
fix: use add CDN_PREFIX environment variable to allow targetting fold…
Browse files Browse the repository at this point in the history
…ers in media storage
  • Loading branch information
rowasc committed Aug 13, 2020
1 parent b850c48 commit dbada5d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Core/Tool/Uploader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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, '/');
Expand Down

0 comments on commit dbada5d

Please sign in to comment.