Skip to content

Commit

Permalink
fix: improve avatar upload functionality
Browse files Browse the repository at this point in the history
Signed-off-by: Sami Mazouz <[email protected]>
  • Loading branch information
SychO9 committed May 20, 2023
1 parent 777c304 commit d1059c1
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion framework/core/js/src/forum/components/AvatarEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ export default class AvatarEditor extends Component {

/**
* 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
* @protected
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ protected function makeImage(UploadedFileInterface $file): Image
]);
}

$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->upsize();
})->encode('png');
Expand Down
2 changes: 1 addition & 1 deletion framework/core/src/Api/Controller/UploadLogoController.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function __construct(SettingsRepositoryInterface $settings, Factory $file
*/
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();
})->encode('png');

Expand Down
2 changes: 1 addition & 1 deletion framework/core/src/User/AvatarValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ protected function assertFileMimes(UploadedFileInterface $file)
}

try {
$this->imageManager->make($file->getStream());
$this->imageManager->make($file->getStream()->getMetadata('uri'));
} catch (NotReadableException $_e) {
$this->raise('image');
}
Expand Down
2 changes: 1 addition & 1 deletion framework/core/src/User/Command/UploadAvatarHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function handle(UploadAvatar $command)

$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(
new AvatarSaving($user, $actor, $image)
Expand Down

0 comments on commit d1059c1

Please sign in to comment.