Laravel-medialibrary: File name normalization

Created on 14 Jun 2016  路  2Comments  路  Source: spatie/laravel-medialibrary

Hello,

where would it be best to put filename normalization?

For example"
"image (1).jpg"
I would like to run "str_slug($filename)", so I get better, error-less filenames?

Thank you

Most helpful comment

You can use usingFileName to set the filename to anything you want:

$yourModel
   ->addMedia($pathToFile)
   ->usingFileName($normalizedFileName)
   ->toMediaLibrary();

All 2 comments

You can use usingFileName to set the filename to anything you want:

$yourModel
   ->addMedia($pathToFile)
   ->usingFileName($normalizedFileName)
   ->toMediaLibrary();

How can I change the name only, not the extension?

Was this page helpful?
0 / 5 - 0 ratings