Skip to content

[2.x] feat: HiDPI avatar srcset (#4554) - #4555

Merged
imorland merged 2 commits into
2.xfrom
im/hiDPI-avatar-srcset
Apr 11, 2026
Merged

imorland merged 2 commits into
2.xfrom
im/hiDPI-avatar-srcset

Conversation

@imorland

Copy link
Copy Markdown
Member

Implements #4554.

Generates @2x (200 px) and @3x (300 px) avatar variants at upload time alongside the existing base (100 px) file. Upscaling is never performed — variants are skipped when the source image is too small. The User API resource exposes a new avatarSrcset field, and the Avatar component passes it through as the HTML srcset attribute.

Changes:

  • AvatarUploader: generates up to three variants per upload using a clone+cover() pattern to avoid mutating the source image; deleteAllVariants() removes all three on avatar removal; srcsetFor() builds the srcset string only when HiDPI variants are present on disk
  • DriverInterface / DefaultDriver: new avatarSrcset() method — custom drivers may override to return a srcset string
  • User: getAvatarSrcsetAttribute() accessor; deleting hook updated to remove all variants via AvatarUploader::deleteAllVariants()
  • UserResource: avatarSrcset schema field; uploadAvatarFromUrl() accepts optional $url2x/$url3x for pre-sized OAuth-provided images
  • Registration: provideAvatar2x() / provideAvatar3x() for OAuth drivers
  • Avatar.tsx / User.tsx: avatarSrcset() model method; srcSet prop on <img>

imorland and others added 2 commits April 11, 2026 16:46
Uploads now produce @2x (200px) and @3x (300px) variants alongside the
base 1× (100px) file when the source image is large enough — upscaling
is never performed. The User API response includes a new `avatarSrcset`
field, and the Avatar component passes it through as the HTML `srcset`
attribute so browsers on retina displays receive appropriately sized
images.

Also extends `Registration` with `provideAvatar2x()`/`provideAvatar3x()`
and `DriverInterface` with `avatarSrcset()` so OAuth drivers and custom
avatar drivers can supply HiDPI URLs directly.

Closes #4554
@imorland imorland added this to the 2.0.0-rc.1 milestone Apr 11, 2026
@imorland imorland linked an issue Apr 11, 2026 that may be closed by this pull request
@imorland
imorland marked this pull request as ready for review April 11, 2026 15:59
@imorland
imorland requested a review from a team as a code owner April 11, 2026 15:59
@imorland
imorland merged commit ba622ed into 2.x Apr 11, 2026
25 checks passed
@imorland
imorland deleted the im/hiDPI-avatar-srcset branch April 11, 2026 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[2.x] Avatars are blurry on HiDPI/retina displays

2 participants