-
-
Notifications
You must be signed in to change notification settings - Fork 841
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: upgrade
intervention/image
to 3.2 (#3947)
* chore: create standalone imageprovider * chore: upgrade intervention to v3 * Apply fixes from StyleCI * use new static instatiation * Revert "Apply fixes from StyleCI" This reverts commit 096b4d9. * get avatar from remote * Apply fixes from StyleCI * fix: incorrect gid exception namespace * fix test * remove debug code --------- Co-authored-by: StyleCI Bot <bot@styleci.io>
- Loading branch information
1 parent
d400dcb
commit e335054
Showing
14 changed files
with
113 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Flarum. | ||
* | ||
* For detailed copyright and license information, please view the | ||
* LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Flarum\Image; | ||
|
||
use Flarum\Foundation\AbstractServiceProvider; | ||
use Flarum\Foundation\Config; | ||
use Illuminate\Contracts\Container\Container; | ||
use Illuminate\Support\Arr; | ||
use Intervention\Image\Drivers; | ||
use Intervention\Image\ImageManager; | ||
use RuntimeException; | ||
|
||
class ImageServiceProvider extends AbstractServiceProvider | ||
{ | ||
public function register(): void | ||
{ | ||
$this->container->bind('image.drivers', function (): array { | ||
return [ | ||
'gd' => Drivers\Gd\Driver::class, | ||
'imagick' => Drivers\Imagick\Driver::class | ||
]; | ||
}); | ||
|
||
$this->container->singleton('image', function (Container $container): ImageManager { | ||
$interventionDrivers = $container->make('image.drivers'); | ||
|
||
$configDriver = $container->make(Config::class)->offsetGet('intervention.driver'); | ||
|
||
// Default to 'gd' if not present in the config | ||
$driver = $configDriver ?? 'gd'; | ||
|
||
// Check that the imagick library is actually available, else default back to gd. | ||
if ($driver === 'imagick' && ! extension_loaded('imagick')) { | ||
$driver = 'gd'; | ||
} | ||
|
||
if (! Arr::has($interventionDrivers, $driver)) { | ||
throw new RuntimeException("intervention/image: $driver is not valid"); | ||
} | ||
|
||
return new ImageManager($interventionDrivers[$driver]); | ||
}); | ||
|
||
$this->container->alias('image', ImageManager::class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters