Skip to content

Commit

Permalink
move ImageManipulator singleton to lazy instantiation
Browse files Browse the repository at this point in the history
avoid issue with intervention/image-laravel not yet being configured

fixes #350
  • Loading branch information
frasmage committed Apr 9, 2024
1 parent 9cfecc7 commit 2eee944
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/MediableServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@

use CreateMediableTables;
use Illuminate\Contracts\Container\Container;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Filesystem\FilesystemManager;
use Illuminate\Support\ServiceProvider;
use Intervention\Image\ImageManager;
use Mimey\MimeTypes;
use Plank\Mediable\Commands\ImportMediaCommand;
use Plank\Mediable\Commands\PruneMediaCommand;
Expand Down Expand Up @@ -188,7 +191,13 @@ public function registerUrlGeneratorFactory(): void

public function registerImageManipulator(): void
{
$this->app->singleton(ImageManipulator::class);
$this->app->singleton(ImageManipulator::class, function (Container $app) {
return new ImageManipulator(
$app->get(ImageManager::class),
$app->get(FilesystemManager::class),
$app->get(ImageOptimizer::class)
);
});
}

/**
Expand Down

0 comments on commit 2eee944

Please sign in to comment.