[2.x] feat: HiDPI avatar srcset (#4554) - #4555
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements #4554.
Generates
@2x(200 px) and@3x(300 px) avatar variants at upload time alongside the existing base1×(100 px) file. Upscaling is never performed — variants are skipped when the source image is too small. TheUserAPI resource exposes a newavatarSrcsetfield, and theAvatarcomponent passes it through as the HTMLsrcsetattribute.Changes:
AvatarUploader: generates up to three variants per upload using aclone+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 diskDriverInterface/DefaultDriver: newavatarSrcset()method — custom drivers may override to return a srcset stringUser:getAvatarSrcsetAttribute()accessor;deletinghook updated to remove all variants viaAvatarUploader::deleteAllVariants()UserResource:avatarSrcsetschema field;uploadAvatarFromUrl()accepts optional$url2x/$url3xfor pre-sized OAuth-provided imagesRegistration:provideAvatar2x()/provideAvatar3x()for OAuth driversAvatar.tsx/User.tsx:avatarSrcset()model method;srcSetprop on<img>