Pass DIY slug when uploading photos.

This commit is contained in:
Aaron van Geffen 2018-02-22 20:02:02 +01:00
parent 068d1dad3e
commit c6c249787f
1 changed files with 4 additions and 0 deletions

View File

@ -33,10 +33,14 @@ class UploadMedia extends HTMLController
if (empty($uploaded_file))
continue;
// DIY slug club.
$slug = $tag->slug . '/' . strtr($uploaded_file['name'], [' ' => '-', '--' => '-', '&' => 'and', '=>' => '', "'" => "", ":"=> "", '\\' => '-']);
$asset = Asset::createNew([
'filename_to_copy' => $uploaded_file['tmp_name'],
'preferred_filename' => $uploaded_file['name'],
'preferred_subdir' => $tag->slug,
'slug' => $slug,
]);
$new_ids[] = $asset->getId();