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:
@@ -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
|
||||||
|
@@ -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');
|
||||||
|
@@ -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');
|
||||||
|
|
||||||
|
@@ -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');
|
||||||
}
|
}
|
||||||
|
@@ -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)
|
||||||
|
Reference in New Issue
Block a user