Skip to content

Commit

Permalink
Merge pull request #124 from mostafaznv/dev
Browse files Browse the repository at this point in the history
fix: return preview url on ckeditor api calls and images on index/detail pages of file resources
  • Loading branch information
mostafaznv authored Apr 5, 2024
2 parents 627b6a6 + 036f8a3 commit 3108ef7
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 11 deletions.
4 changes: 0 additions & 4 deletions docs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
* [Customize ImageStorage](advanced-usage/customize-imagestorage.md)
* [Integrating NovaFileArtisan (Larupload) with Image Resource](advanced-usage/integrating-novafileartisan-larupload-with-image-resource.md)
* [Customize AudioStorage](advanced-usage/customize-audiostorage.md)
* [Customize FileStorage](advanced-usage/customize-audiostorage-1.md)
* [Multiple Toolbars](advanced-usage/multiple-toolbars.md)
* [Customize Toolbar Items](advanced-usage/customize-toolbar-items.md)
* [Media Embed](advanced-usage/media-embed.md)
Expand All @@ -33,7 +32,6 @@
* [Image Browser](advanced-usage/ckeditor-field-options/image-browser.md)
* [Audio Browser](advanced-usage/ckeditor-field-options/audio-browser.md)
* [Video Browser](advanced-usage/ckeditor-field-options/video-browser.md)
* [File Browser](advanced-usage/ckeditor-field-options/audio-browser-1.md)
* [Snippets](advanced-usage/ckeditor-field-options/snippets.md)
* [Configuration](advanced-usage/configuration/README.md)
* [Video Model](advanced-usage/configuration/video-model.md)
Expand All @@ -44,7 +42,6 @@
* [Image Max Height](advanced-usage/configuration/image-max-height.md)
* [Image Naming Method](advanced-usage/configuration/image-naming-method.md)
* [Audio Naming Method](advanced-usage/configuration/audio-naming-method.md)
* [File Naming Method](advanced-usage/configuration/audio-naming-method-1.md)
* [Toolbars](advanced-usage/configuration/toolbars/README.md)
* [Defualt Toolbar](advanced-usage/configuration/toolbars/defualt-toolbar.md)
* [Toolbar 1](advanced-usage/configuration/toolbars/toolbar-1/README.md)
Expand All @@ -61,7 +58,6 @@
* [Image Browser](advanced-usage/configuration/toolbars/toolbar-1/image-browser.md)
* [Audio Browser](advanced-usage/configuration/toolbars/toolbar-1/audio-browser.md)
* [Video Browser](advanced-usage/configuration/toolbars/toolbar-1/video-browser.md)
* [File Browser](advanced-usage/configuration/toolbars/toolbar-1/audio-browser-1.md)
* [Insert Image Types](advanced-usage/configuration/toolbars/toolbar-1/insert-image-types.md)
* [Insert Image Size](advanced-usage/configuration/toolbars/toolbar-1/insert-image-size.md)
* [Snippets](advanced-usage/configuration/toolbars/toolbar-1/snippets.md)
Expand Down
35 changes: 35 additions & 0 deletions docs/other/migration.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,40 @@
# Migration

### **From 7.2.1 to 7.3.0**

Starting from v7.3.0, we introduced a <mark style="color:red;">files</mark> section to the <mark style="color:red;">media picker</mark>. However, to prevent users from encountering 500 errors, we've disabled it by <mark style="color:red;">default</mark>. If you wish to enable it, follow these simple steps:

1. Update the `config/nova-ckeditor.php` file and add <mark style="color:red;">file-naming-method</mark> and <mark style="color:red;">toolbars.toolbar-1.browser.file</mark> to it. For further information, please refer the [original config file](https://github.com/mostafaznv/nova-ckeditor/blob/master/config/nova-ckeditor.php).
2. Add `file` disk to `config/filesystems.php` file:

```php
'disks' => [
'file' => [
'driver' => 'local',
'root' => public_path('uploads/file'),
'url' => env('APP_URL') . '/uploads/file',
]
]
```

3. Rerun the publish command to publish the model, nova resource, and migration files for the file picker:

```sh
php artisan vendor:publish --provider="Mostafaznv\NovaCkEditor\FieldServiceProvider"
```

4. Migrate&#x20;

```sh
php artisan migrate
```

That's it! Your changes should now be applied.





### **From 6.2.1 to 7.0.0**

We have undertaken significant refactoring efforts to release version <mark style="color:red;">7.0.0</mark>. Despite our best efforts to avoid introducing any breaking changes, it became necessary due to the merging of all types of media pickers (<mark style="color:blue;">audio</mark>, <mark style="color:blue;">video</mark>, and <mark style="color:blue;">image</mark>).
Expand Down
14 changes: 7 additions & 7 deletions src/FileUpload.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ public function __construct(string $name, ?string $attribute = null, string $dis
{
parent::__construct($name, $attribute ?? 'file', $disk, app('ckeditor-file-storage', compact('disk')));

$this->thumbnail(function ($value) {
if ($value and str_contains($this->resource->mime, 'image')) {
return Storage::disk($this->getStorageDisk())->url($value);
}

return null;
});

$this->preview(function ($value, $disk, $model) {
return $value ? Storage::disk($this->getStorageDisk())->url($value) : null;
if ($value) {
if (request()->query('ckeditor') == 'media' or str_contains($this->resource->mime, 'image')) {
return Storage::disk($this->getStorageDisk())->url($value);
}
}

return null;
});

$this->deletable(NovaRequest::capture()->isCreateOrAttachRequest());
Expand Down

0 comments on commit 3108ef7

Please sign in to comment.