Skip to content
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

[NEW] Accept GIFs and SVGs for Avatars converting them to PNG and keep transparency of PNGs #11385

Merged
merged 5 commits into from
Oct 20, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/rocketchat-file-upload/server/lib/FileUpload.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ Object.assign(FileUpload, {
metadata = {};
}

s.toFormat(sharp.format.jpeg)
s.toFormat(sharp.format.png)
.resize(Math.min(height || 0, metadata.width || Infinity), Math.min(height || 0, metadata.height || Infinity))
.pipe(sharp()
.resize(height, height)
.background('#FFFFFF')
.background({ r: 0, g: 0, b: 0, alpha: 0 })
.embed()
)
// Use buffer to get the result in memory then replace the existing file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
width: var(--select-avatar-preview-size);
height: var(--select-avatar-preview-size);
margin-right: 1rem;

background-color: transparent;
background-image: linear-gradient(45deg, var(--color-gray) 25%, transparent 25%, transparent 75%, var(--color-gray) 75%, var(--color-gray)),
linear-gradient(45deg, var(--color-gray) 25%, transparent 25%, transparent 75%, var(--color-gray) 75%, var(--color-gray));
background-size: 10px 10px;
background-position: 0 0, 5px 5px;
}

&__loading::after {
Expand Down