1
0
mirror of https://github.com/flarum/core.git synced 2025-08-05 07:57:46 +02:00

fix: improve avatar upload functionality

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
This commit is contained in:
Sami Mazouz
2023-05-20 10:51:26 +01:00
parent 777c304ab7
commit d1059c1cc7
5 changed files with 5 additions and 5 deletions

View File

@@ -204,7 +204,7 @@ export default class AvatarEditor extends Component {
/** /**
* After a successful upload/removal, push the updated user data into the * After a successful upload/removal, push the updated user data into the
* store, and force a recomputation of the user's avatar color. * store, and force a re-computation of the user's avatar color.
* *
* @param {object} response * @param {object} response
* @protected * @protected

View File

@@ -62,7 +62,7 @@ class UploadFaviconController extends UploadImageController
]); ]);
} }
$encodedImage = $this->imageManager->make($file->getStream())->resize(64, 64, function ($constraint) { $encodedImage = $this->imageManager->make($file->getStream()->getMetadata('uri'))->resize(64, 64, function ($constraint) {
$constraint->aspectRatio(); $constraint->aspectRatio();
$constraint->upsize(); $constraint->upsize();
})->encode('png'); })->encode('png');

View File

@@ -38,7 +38,7 @@ class UploadLogoController extends UploadImageController
*/ */
protected function makeImage(UploadedFileInterface $file): Image protected function makeImage(UploadedFileInterface $file): Image
{ {
$encodedImage = $this->imageManager->make($file->getStream())->heighten(60, function ($constraint) { $encodedImage = $this->imageManager->make($file->getStream()->getMetadata('uri'))->heighten(60, function ($constraint) {
$constraint->upsize(); $constraint->upsize();
})->encode('png'); })->encode('png');

View File

@@ -87,7 +87,7 @@ class AvatarValidator extends AbstractValidator
} }
try { try {
$this->imageManager->make($file->getStream()); $this->imageManager->make($file->getStream()->getMetadata('uri'));
} catch (NotReadableException $_e) { } catch (NotReadableException $_e) {
$this->raise('image'); $this->raise('image');
} }

View File

@@ -74,7 +74,7 @@ class UploadAvatarHandler
$this->validator->assertValid(['avatar' => $command->file]); $this->validator->assertValid(['avatar' => $command->file]);
$image = $this->imageManager->make($command->file->getStream()); $image = $this->imageManager->make($command->file->getStream()->getMetadata('uri'));
$this->events->dispatch( $this->events->dispatch(
new AvatarSaving($user, $actor, $image) new AvatarSaving($user, $actor, $image)