Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable File Rename via Config #479

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,13 @@ to `false` in the config file. The default is `true`.
],
```

If you wish to disable renaming the actual file when the user renames the media asset, set the `rename_on_update` config
value to `false`. The default value is `true`.

```php
'rename_on_update' => false
```

### Glider Blade Component

To make it as easy as possible to output your media, Curator comes with an
Expand Down
3 changes: 2 additions & 1 deletion config/curator.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,6 @@
'multi_select_key' => 'metaKey',
'table' => [
'layout' => 'grid',
]
],
'rename_on_update' => true
];
2 changes: 1 addition & 1 deletion src/Observers/MediaObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function updating(Media $media): void
}

// Rename file name
if ($media->isDirty(['name']) && ! blank($media->name)) {
if ($media->isDirty(['name']) && ! blank($media->name) && config('curator.rename_on_update')) {
if (Storage::disk($media->disk)->exists($media->directory . '/' . $media->name . '.' . $media->ext)) {
$media->name = $media->name . '-' . time();
}
Expand Down