1
0
mirror of https://github.com/flarum/core.git synced 2025-10-19 10:46:06 +02:00

feat: Allow switching the ImageManager driver (#3195)

This commit is contained in:
Ian Morland
2021-12-12 21:34:10 +00:00
committed by GitHub
parent 7be0c02ba1
commit bd8ebb00a0
6 changed files with 81 additions and 12 deletions

View File

@@ -28,15 +28,21 @@ class UploadFaviconController extends UploadImageController
*/
protected $translator;
/**
* @var ImageManager
*/
protected $imageManager;
/**
* @param SettingsRepositoryInterface $settings
* @param Factory $filesystemFactory
*/
public function __construct(SettingsRepositoryInterface $settings, Factory $filesystemFactory, TranslatorInterface $translator)
public function __construct(SettingsRepositoryInterface $settings, Factory $filesystemFactory, TranslatorInterface $translator, ImageManager $imageManager)
{
parent::__construct($settings, $filesystemFactory);
$this->translator = $translator;
$this->imageManager = $imageManager;
}
/**
@@ -56,9 +62,7 @@ class UploadFaviconController extends UploadImageController
]);
}
$manager = new ImageManager();
$encodedImage = $manager->make($file->getStream())->resize(64, 64, function ($constraint) {
$encodedImage = $this->imageManager->make($file->getStream())->resize(64, 64, function ($constraint) {
$constraint->aspectRatio();
$constraint->upsize();
})->encode('png');