|
3 | 3 | namespace UniSharp\LaravelFilemanager;
|
4 | 4 |
|
5 | 5 | use Illuminate\Container\Container;
|
6 |
| -use Intervention\Image\Facades\Image; |
| 6 | +use Intervention\Image\Facades\Image as InterventionImageV2; |
| 7 | +use Intervention\Image\Laravel\Facades\Image as InterventionImageV3; |
7 | 8 | use Symfony\Component\HttpFoundation\File\UploadedFile;
|
8 | 9 | use UniSharp\LaravelFilemanager\Events\FileIsUploading;
|
9 | 10 | use UniSharp\LaravelFilemanager\Events\FileWasUploaded;
|
@@ -234,7 +235,6 @@ public function upload($file)
|
234 | 235 | \Log::info($e);
|
235 | 236 | return $this->error('invalid');
|
236 | 237 | }
|
237 |
| - // TODO should be "FileWasUploaded" |
238 | 238 | event(new FileWasUploaded($new_file_path));
|
239 | 239 | event(new ImageWasUploaded($new_file_path));
|
240 | 240 |
|
@@ -322,9 +322,19 @@ public function generateThumbnail($file_name)
|
322 | 322 | $this->setName($file_name)->thumb(true);
|
323 | 323 | $thumbWidth = $this->helper->shouldCreateCategoryThumb() && $this->helper->categoryThumbWidth() ? $this->helper->categoryThumbWidth() : config('lfm.thumb_img_width', 200);
|
324 | 324 | $thumbHeight = $this->helper->shouldCreateCategoryThumb() && $this->helper->categoryThumbHeight() ? $this->helper->categoryThumbHeight() : config('lfm.thumb_img_height', 200);
|
325 |
| - $image = Image::make($original_image->get()) |
326 |
| - ->fit($thumbWidth, $thumbHeight); |
327 | 325 |
|
328 |
| - $this->storage->put($image->stream()->detach(), 'public'); |
| 326 | + if (class_exists(InterventionImageV2::class)) { |
| 327 | + $encoded_image = InterventionImageV2::make($original_image->get()) |
| 328 | + ->fit($thumbWidth, $thumbHeight) |
| 329 | + ->stream() |
| 330 | + ->detach(); |
| 331 | + } else { |
| 332 | + $encoded_image = InterventionImageV3::read($original_image->get()) |
| 333 | + ->cover($thumbWidth, $thumbHeight) |
| 334 | + ->encodeByMediaType(); |
| 335 | + } |
| 336 | + |
| 337 | + |
| 338 | + $this->storage->put($encoded_image, 'public'); |
329 | 339 | }
|
330 | 340 | }
|
0 commit comments