Skip to content

Commit 828ddef

Browse files
authored
Merge pull request #48 from advoor/s3-fix
S3 fix
2 parents 70f48f6 + 2368f01 commit 828ddef

4 files changed

Lines changed: 54 additions & 8 deletions

File tree

dist/js/field.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/js/field.js.LICENSE.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
/**
1111
* @license
1212
* Lodash <https://lodash.com/>
13-
* Copyright JS Foundation and other contributors <https://js.foundation/>
13+
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
1414
* Released under MIT license <https://lodash.com/license>
1515
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
1616
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
@@ -87,8 +87,7 @@
8787
/**
8888
* Raw HTML Tool for CodeX Editor
8989
*
90-
* @author CodeX (team@ifmo.su)
90+
* @author CodeX (team@codex.so)
9191
* @copyright CodeX 2018
9292
* @license The MIT License (MIT)
93-
* @version 2.0.0
9493
*/

resources/js/components/FormField.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@
5050
* Initial Editor data
5151
*/
5252
data: currentContent,
53+
54+
/**
55+
* Min height of editor
56+
*/
57+
minHeight: 35,
58+
5359
onReady: function () {
5460
5561
},

src/Http/Controllers/EditorJsImageUploadController.php

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,22 @@ public function file(NovaRequest $request)
3434
config('nova-editor-js.toolSettings.image.disk')
3535
);
3636

37-
$this->applyAlterations(Storage::disk(config('nova-editor-js.toolSettings.image.disk'))->path($path));
38-
$thumbnails = $this->applyThumbnails($path);
37+
if (config('nova-editor-js.toolSettings.image.disk') !== 'local') {
38+
39+
$tempPath = $request->file('image')->store(
40+
config('nova-editor-js.toolSettings.image.path'),
41+
'local'
42+
);
43+
44+
$this->applyAlterations(Storage::disk('local')->path($tempPath));
45+
$thumbnails = $this->applyThumbnails($tempPath);
46+
47+
$this->deleteThumbnails(Storage::disk('local')->path($tempPath));
48+
Storage::disk('local')->delete($path);
49+
} else {
50+
$this->applyAlterations(Storage::disk(config('nova-editor-js.toolSettings.image.disk'))->path($path));
51+
$thumbnails = $this->applyThumbnails($path);
52+
}
3953

4054
return [
4155
'success' => 1,
@@ -108,7 +122,7 @@ private function applyAlterations($path, $alterations = [])
108122
$imageSettings = $alterations;
109123
}
110124

111-
if(empty($imageSettings))
125+
if (empty($imageSettings))
112126
return;
113127

114128
if (!empty($imageSettings['resize']['width'])) {
@@ -181,7 +195,13 @@ private function applyThumbnails($path)
181195

182196
Storage::disk(config('nova-editor-js.toolSettings.image.disk'))->copy($path, $newThumbnailPath);
183197

184-
$newPath = Storage::disk(config('nova-editor-js.toolSettings.image.disk'))->path($newThumbnailPath);
198+
if (config('nova-editor-js.toolSettings.image.disk') !== 'local') {
199+
Storage::disk('local')->copy($path, $newThumbnailPath);
200+
$newPath = Storage::disk('local')->path($newThumbnailPath);
201+
} else {
202+
$newPath = Storage::disk(config('nova-editor-js.toolSettings.image.disk'))->path($newThumbnailPath);
203+
}
204+
185205
$this->applyAlterations($newPath, $setting);
186206

187207
$generatedThumbnails[] = Storage::disk(config('nova-editor-js.toolSettings.image.disk'))->url($newThumbnailPath);
@@ -190,4 +210,25 @@ private function applyThumbnails($path)
190210

191211
return $generatedThumbnails;
192212
}
213+
214+
215+
/**
216+
* @param $path
217+
*/
218+
private function deleteThumbnails($path)
219+
{
220+
$thumbnailSettings = config('nova-editor-js.toolSettings.image.thumbnails');
221+
222+
if (!empty($thumbnailSettings)) {
223+
foreach ($thumbnailSettings as $thumbnailName => $setting) {
224+
$filename = pathinfo($path, PATHINFO_FILENAME);
225+
$extension = pathinfo($path, PATHINFO_EXTENSION);
226+
227+
$newThumbnailName = $filename . $thumbnailName . '.' . $extension;
228+
$newThumbnailPath = config('nova-editor-js.toolSettings.image.path') . '/' . $newThumbnailName;
229+
230+
Storage::disk('local')->delete($path, $newThumbnailPath);
231+
}
232+
}
233+
}
193234
}

0 commit comments

Comments
 (0)