Skip to content

Commit 3b0d57f

Browse files
authored
Merge pull request #4 from advoor/image-tool-tweaks
Allow path and disk to be specified using a config file
2 parents 7f4107e + d393895 commit 3b0d57f

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/Http/Controllers/EditorJsImageUploadController.php

+8-5
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,15 @@ public function file(NovaRequest $request)
2727
];
2828
}
2929

30-
$path = $request->file('image')->store('public/images');
30+
$path = $request->file('image')->store(
31+
config('nova-editor-js.image.path'),
32+
config('nova-editor-js.image.disk')
33+
);
3134

3235
return [
3336
'success' => 1,
3437
'file' => [
35-
'url' => Storage::url($path)
38+
'url' => Storage::disk(config('nova-editor-js.image.disk'))->url($path)
3639
]
3740
];
3841
}
@@ -72,14 +75,14 @@ function ($attribute, $value, $fail) {
7275
$url = $request->input('url');
7376
$imageContents = file_get_contents($url);
7477
$name = substr($url, strrpos($url, '/') + 1);
75-
$nameWithPath = 'public/images/' . uniqid() . $name;
78+
$nameWithPath = config('nova-editor-js.image.path') . '/' . uniqid() . $name;
7679

77-
Storage::put($nameWithPath, $imageContents);
80+
Storage::disk(config('nova-editor-js.image.disk'))->put($nameWithPath, $imageContents);
7881

7982
return [
8083
'success' => 1,
8184
'file' => [
82-
'url' => Storage::url($nameWithPath)
85+
'url' => Storage::disk(config('nova-editor-js.image.disk'))->url($nameWithPath)
8386
]
8487
];
8588
}

src/config/nova-editor-js.php

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
<?php
22

33
return [
4+
'image' => [
5+
'path' => 'public/images',
6+
'disk' => 'local'
7+
],
8+
49
'tools' => [
510
'header' => [
611
'text' => [

0 commit comments

Comments
 (0)