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 a given base path, including only variants that exist on disk.
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 99
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 124
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 140
string|null
srcsetFor(string $basePath)
Return the srcset string for a given base path, including only variants that exist on disk.
Returns null if only the base file exists (no HiDPI variants).
at
line 176
protected array
variantPaths(string $basePath)
Return all variant paths (base + @2x + @3x) for a given base path.
at
line 187
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').