-
Notifications
You must be signed in to change notification settings - Fork 136
bug: image rescaling fix #1292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug: image rescaling fix #1292
Conversation
Reviewer's GuideThis PR refactors the avatar upload flow by replacing fixed-size logic with configurable constants, tracking and logging actual file sizes, and introducing client-side downscaling via a new createAvatarBlob helper; update() is converted to an async workflow with robust upload error handling. Sequence diagram for the updated avatar upload and downscaling processsequenceDiagram
actor User
participant "ChangeAvatar.vue"
participant "createAvatarBlob()"
participant "api.uploadFile()"
User->>"ChangeAvatar.vue": Selects avatar image
"ChangeAvatar.vue"->>"createAvatarBlob()": Downscale image on client
"createAvatarBlob()"-->>"ChangeAvatar.vue": Returns resized blob and dimension
"ChangeAvatar.vue"->>"api.uploadFile()": Upload resized image
"api.uploadFile()"-->>"ChangeAvatar.vue": Returns upload response
"ChangeAvatar.vue"->>User: Shows success or error message
Class diagram for updated ChangeAvatar.vue avatar upload logicclassDiagram
class ChangeAvatar {
+MIN_AVATAR_SIZE: number
+UPLOAD_AVATAR_SIZE: number
+selectedFileSize: number
+update()
+createAvatarBlob(sourceCanvas)
}
ChangeAvatar : update() async
ChangeAvatar : createAvatarBlob(sourceCanvas) Promise<{blob, dimension}>
ChangeAvatar : fileSelected(event)
ChangeAvatar : changeIdenticon()
ChangeAvatar : pixelsRestrictions({minWidth, minHeight, maxWidth, maxHeight})
ChangeAvatar : avatarImage
ChangeAvatar : fileError
ChangeAvatar : changedImage
ChangeAvatar : cropperRef
ChangeAvatar : identiconUser
ChangeAvatar : identiconValue
ChangeAvatar : emit()
ChangeAvatar : api.uploadFile(blob, filename, null, width, height)
ChangeAvatar : error handling for upload
ChangeAvatar : logs file sizes
Flow diagram for avatar image downscaling and uploadflowchart TD
A[User selects avatar image] --> B[Validate file size and dimensions]
B --> C{Image valid?}
C -- No --> D[Show error]
C -- Yes --> E[Downscale image with createAvatarBlob]
E --> F[Upload resized image]
F --> G{Upload success?}
G -- No --> H[Show upload error]
G -- Yes --> I[Update avatar URL]
File-Level Changes
Assessment against linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes avatar upload errors by implementing on-the-fly image downscaling to ensure avatars conform to size limits and prevent oversized file uploads (issue #1286).
Key Changes:
- Introduces
MIN_AVATAR_SIZE(128px) andUPLOAD_AVATAR_SIZE(256px) constants to standardize size validation and enforce upload limits - Implements
createAvatarBlob()function that downscales images to maximum 256px while maintaining quality using canvas API - Refactors
update()function to async with comprehensive error handling for HTTP status codes and content-type validation
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
mariobehling
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check AI reviews.
189568e to
39d65c1
Compare
39d65c1 to
fcf30fa
Compare
|
updated |
Fixes #1286 by implementing downscaling
2025-11-15.13-24-01.mp4
Summary by Sourcery
Implement configurable downscaling of avatars in ChangeAvatar component, standardize size constants, refactor upload logic to async with improved error handling, and add logging of image sizes
New Features:
Bug Fixes:
Enhancements: