Skip to content

Commit

Permalink
replace spaces with dashes in media filenames
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott Merrill committed Apr 16, 2019
1 parent 8ac1970 commit 66d7390
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion inc/media.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ function media_upload($file, $target_dir, $max_width) {
$ext = 'jpeg';
}
# define our own name for this file.
$orig = explode('.', $file['name'])[0];
# and replace spaces with dashes, for sanity and safety
$orig = str_replace(' ', '-', explode('.', $file['name'])[0]);
$date = new DateTime();
$filename = $orig . '-' . $date->format('u') . "-$max_width.$ext";
# extra caution to ensure the file doesn't already exist
Expand Down

0 comments on commit 66d7390

Please sign in to comment.