@@ -71,8 +71,8 @@ public function file(Request $request): JsonResponse
71
71
'success ' => 1 ,
72
72
'file ' => [
73
73
'url ' => Storage::disk (config ('nova-editor-js.toolSettings.image.disk ' ))->url ($ path ),
74
- 'thumbnails ' => $ thumbnails
75
- ]
74
+ 'thumbnails ' => $ thumbnails,
75
+ ],
76
76
]);
77
77
}
78
78
@@ -96,35 +96,35 @@ public function url(Request $request): JsonResponse
96
96
// Fetch URL
97
97
try {
98
98
$ response = Http::timeout (5 )->get ($ url )->throw ();
99
- } catch (ConnectionException | RequestException ) {
99
+ } catch (ConnectionException | RequestException ) {
100
100
return response ()->json ([
101
101
'success ' => 0 ,
102
102
]);
103
103
}
104
104
105
105
// Validate mime type
106
106
$ mime = (new finfo ())->buffer ($ response ->body (), FILEINFO_MIME_TYPE );
107
- if (!in_array ($ mime , self ::VALID_IMAGE_MIMES , true )) {
107
+ if (! in_array ($ mime , self ::VALID_IMAGE_MIMES , true )) {
108
108
return response ()->json ([
109
109
'success ' => 0 ,
110
110
]);
111
111
}
112
112
113
113
$ urlBasename = basename (parse_url (url ($ url ), PHP_URL_PATH ));
114
- $ nameWithPath = config ('nova-editor-js.toolSettings.image.path ' ) . '/ ' . uniqid () . $ urlBasename ;
114
+ $ nameWithPath = config ('nova-editor-js.toolSettings.image.path ' ). '/ ' . uniqid (). $ urlBasename ;
115
115
Storage::disk (config ('nova-editor-js.toolSettings.image.disk ' ))->put ($ nameWithPath , $ response ->body ());
116
116
event (new EditorJsImageUploaded (config ('nova-editor-js.toolSettings.image.disk ' ), $ nameWithPath ));
117
117
118
118
return response ()->json ([
119
119
'success ' => 1 ,
120
120
'file ' => [
121
- 'url ' => Storage::disk (config ('nova-editor-js.toolSettings.image.disk ' ))->url ($ nameWithPath )
122
- ]
121
+ 'url ' => Storage::disk (config ('nova-editor-js.toolSettings.image.disk ' ))->url ($ nameWithPath ),
122
+ ],
123
123
]);
124
124
}
125
125
126
126
/**
127
- * @param array $alterations
127
+ * @param array $alterations
128
128
*/
129
129
private function applyAlterations ($ path , $ alterations = [])
130
130
{
@@ -133,54 +133,54 @@ private function applyAlterations($path, $alterations = [])
133
133
134
134
$ imageSettings = config ('nova-editor-js.toolSettings.image.alterations ' );
135
135
136
- if (!empty ($ alterations )) {
136
+ if (! empty ($ alterations )) {
137
137
$ imageSettings = $ alterations ;
138
138
}
139
139
140
140
if (empty ($ imageSettings )) {
141
141
return ;
142
142
}
143
143
144
- if (!empty ($ imageSettings ['resize ' ]['width ' ])) {
144
+ if (! empty ($ imageSettings ['resize ' ]['width ' ])) {
145
145
$ image ->width ($ imageSettings ['resize ' ]['width ' ]);
146
146
}
147
147
148
- if (!empty ($ imageSettings ['resize ' ]['height ' ])) {
148
+ if (! empty ($ imageSettings ['resize ' ]['height ' ])) {
149
149
$ image ->height ($ imageSettings ['resize ' ]['height ' ]);
150
150
}
151
151
152
- if (!empty ($ imageSettings ['optimize ' ])) {
152
+ if (! empty ($ imageSettings ['optimize ' ])) {
153
153
$ image ->optimize ();
154
154
}
155
155
156
- if (!empty ($ imageSettings ['adjustments ' ]['brightness ' ])) {
156
+ if (! empty ($ imageSettings ['adjustments ' ]['brightness ' ])) {
157
157
$ image ->brightness ($ imageSettings ['adjustments ' ]['brightness ' ]);
158
158
}
159
159
160
- if (!empty ($ imageSettings ['adjustments ' ]['contrast ' ])) {
160
+ if (! empty ($ imageSettings ['adjustments ' ]['contrast ' ])) {
161
161
$ image ->contrast ($ imageSettings ['adjustments ' ]['contrast ' ]);
162
162
}
163
163
164
- if (!empty ($ imageSettings ['adjustments ' ]['gamma ' ])) {
164
+ if (! empty ($ imageSettings ['adjustments ' ]['gamma ' ])) {
165
165
$ image ->gamma ($ imageSettings ['adjustments ' ]['gamma ' ]);
166
166
}
167
167
168
- if (!empty ($ imageSettings ['effects ' ]['blur ' ])) {
168
+ if (! empty ($ imageSettings ['effects ' ]['blur ' ])) {
169
169
$ image ->blur ($ imageSettings ['effects ' ]['blur ' ]);
170
170
}
171
171
172
- if (!empty ($ imageSettings ['effects ' ]['pixelate ' ])) {
172
+ if (! empty ($ imageSettings ['effects ' ]['pixelate ' ])) {
173
173
$ image ->pixelate ($ imageSettings ['effects ' ]['pixelate ' ]);
174
174
}
175
175
176
- if (!empty ($ imageSettings ['effects ' ]['greyscale ' ])) {
176
+ if (! empty ($ imageSettings ['effects ' ]['greyscale ' ])) {
177
177
$ image ->greyscale ();
178
178
}
179
- if (!empty ($ imageSettings ['effects ' ]['sepia ' ])) {
179
+ if (! empty ($ imageSettings ['effects ' ]['sepia ' ])) {
180
180
$ image ->sepia ();
181
181
}
182
182
183
- if (!empty ($ imageSettings ['effects ' ]['sharpen ' ])) {
183
+ if (! empty ($ imageSettings ['effects ' ]['sharpen ' ])) {
184
184
$ image ->sharpen ($ imageSettings ['effects ' ]['sharpen ' ]);
185
185
}
186
186
@@ -199,13 +199,13 @@ private function applyThumbnails($path)
199
199
200
200
$ generatedThumbnails = [];
201
201
202
- if (!empty ($ thumbnailSettings )) {
202
+ if (! empty ($ thumbnailSettings )) {
203
203
foreach ($ thumbnailSettings as $ thumbnailName => $ setting ) {
204
204
$ filename = pathinfo ($ path , PATHINFO_FILENAME );
205
205
$ extension = pathinfo ($ path , PATHINFO_EXTENSION );
206
206
207
- $ newThumbnailName = $ filename . $ thumbnailName . '. ' . $ extension ;
208
- $ newThumbnailPath = config ('nova-editor-js.toolSettings.image.path ' ) . '/ ' . $ newThumbnailName ;
207
+ $ newThumbnailName = $ filename. $ thumbnailName. '. ' . $ extension ;
208
+ $ newThumbnailPath = config ('nova-editor-js.toolSettings.image.path ' ). '/ ' . $ newThumbnailName ;
209
209
210
210
Storage::disk (config ('nova-editor-js.toolSettings.image.disk ' ))->copy ($ path , $ newThumbnailPath );
211
211
@@ -227,20 +227,17 @@ private function applyThumbnails($path)
227
227
return $ generatedThumbnails ;
228
228
}
229
229
230
-
231
- /**
232
- */
233
230
private function deleteThumbnails ($ path )
234
231
{
235
232
$ thumbnailSettings = config ('nova-editor-js.toolSettings.image.thumbnails ' );
236
233
237
- if (!empty ($ thumbnailSettings )) {
234
+ if (! empty ($ thumbnailSettings )) {
238
235
foreach ($ thumbnailSettings as $ thumbnailName => $ setting ) {
239
236
$ filename = pathinfo ($ path , PATHINFO_FILENAME );
240
237
$ extension = pathinfo ($ path , PATHINFO_EXTENSION );
241
238
242
- $ newThumbnailName = $ filename . $ thumbnailName . '. ' . $ extension ;
243
- $ newThumbnailPath = config ('nova-editor-js.toolSettings.image.path ' ) . '/ ' . $ newThumbnailName ;
239
+ $ newThumbnailName = $ filename. $ thumbnailName. '. ' . $ extension ;
240
+ $ newThumbnailPath = config ('nova-editor-js.toolSettings.image.path ' ). '/ ' . $ newThumbnailName ;
244
241
245
242
Storage::disk ('local ' )->delete ($ path , $ newThumbnailPath );
246
243
}
0 commit comments