class AvatarUploader
Constants
| SIZES |
Sizes to generate: base (1×), @2x, @3x. |
Properties
| protected Cloud | $uploadDir |
|
Methods
Upload pre-sized avatar images provided by an OAuth driver.
Handle the removal of the old avatar file after a successful user save.
Delete the base file and all HiDPI variants (@2x, @3x) for a given base path.
Return the srcset string for the user's locally-stored avatar, including only variants that the user record reports as present (`has_avatar_2x` / `has_avatar_3x`). Returns null if the avatar is external, missing, or has no HiDPI variants — this avoids any filesystem `exists()` calls in the read path.
Return all variant paths (base + @2x + @3x) for a given base path.
Derive a variant path from the base path and a suffix (e.g. '' → 'abc.webp', '@2x' → 'abc@2x.webp').
Details
at
line 28
__construct(Factory $filesystemFactory)
at
line 43
void
uploadPresized(User $user, ImageInterface $image1x, ImageInterface|null $image2x, ImageInterface|null $image3x)
Upload pre-sized avatar images provided by an OAuth driver.
The caller is responsible for providing correctly sized images. Only the variants whose images are non-null are stored.
at
line 108
protected void
removeFileAfterSave(User $user)
Handle the removal of the old avatar file after a successful user save.
We don't place this in remove() because otherwise we would call changeAvatarPath 2 times when uploading.
at
line 135
void
deleteAllVariants(string $basePath)
Delete the base file and all HiDPI variants (@2x, @3x) for a given base path.
Safe to call with external URLs — the filesystem exists() check guards against it.
at
line 153
string|null
srcsetFor(User $user)
Return the srcset string for the user's locally-stored avatar, including only variants that the user record reports as present (`has_avatar_2x` / `has_avatar_3x`). Returns null if the avatar is external, missing, or has no HiDPI variants — this avoids any filesystem `exists()` calls in the read path.
at
line 181
protected array
variantPaths(string $basePath)
Return all variant paths (base + @2x + @3x) for a given base path.
at
line 192
protected string
variantPath(string $basePath, string $suffix)
Derive a variant path from the base path and a suffix (e.g. '' → 'abc.webp', '@2x' → 'abc@2x.webp').