WIP
This commit is contained in:
30
app/Support/ShortFileNamer.php
Normal file
30
app/Support/ShortFileNamer.php
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\Support;
|
||||||
|
|
||||||
|
use Spatie\MediaLibrary\Support\FileNamer\FileNamer;
|
||||||
|
use Spatie\MediaLibrary\Conversions\Conversion;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
class ShortFileNamer extends FileNamer
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Keep the original file name exactly as it was uploaded.
|
||||||
|
*/
|
||||||
|
public function originalFileName(string $fileName): string
|
||||||
|
{
|
||||||
|
return pathinfo($fileName, PATHINFO_FILENAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function conversionFileName(string $fileName, Conversion $conversion): string
|
||||||
|
{
|
||||||
|
return Str::random(12);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function responsiveFileName(string $fileName): string
|
||||||
|
{
|
||||||
|
return 'res';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -58,7 +58,7 @@ return [
|
|||||||
/*
|
/*
|
||||||
* This is the class that is responsible for naming generated files.
|
* This is the class that is responsible for naming generated files.
|
||||||
*/
|
*/
|
||||||
'file_namer' => Spatie\MediaLibrary\Support\FileNamer\DefaultFileNamer::class,
|
'file_namer' => App\Support\ShortFileNamer::class,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The class that contains the strategy for determining a media file's path.
|
* The class that contains the strategy for determining a media file's path.
|
||||||
|
|||||||
Reference in New Issue
Block a user