[NEW] Allow request avatar placeholders as PNG or JPG instead of SVG#8193
Merged
[NEW] Allow request avatar placeholders as PNG or JPG instead of SVG#8193
Conversation
lindoelio
commented
Sep 18, 2017
server/startup/avatar.js
Outdated
|
|
||
| res.write(svg); | ||
| res.end(); | ||
| const svg = `<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<svg xmlns=\"http://www.w3.org/2000/svg\" pointer-events=\"none\" width=\"150\" height=\"150\">\n<rect height=\"150\" width=\"150\" fill=\"${ color }\"/>\n<text y=\"50%\" x=\"50%\" pointer-events=\"auto\" fill=\"#ffffff\" font-family=\"Helvetica, Arial, Lucida Grande, sans-serif\" font-weight=\"400\" font-size=\"72\">\n<tspan y=\"67%\" x=\"50%\" text-anchor=\"middle\">${ initials }</tspan>\n</text>\n</svg>`; |
Contributor
Author
There was a problem hiding this comment.
Alignment improvements for the generated SVG.
Contributor
|
@rodrigok Do we want default initials avatar to be PNG by default (if GraphicsMagick or ImageMagick was installed)? |
Contributor
Author
|
@rodrigok It's the short time solution about that we did talk in a recent video call so provides a better way for mobile apps to handle user avatar request. Can you make a review? |
# Conflicts: # server/startup/avatar.js
68f5395 to
56fd1cc
Compare
server/startup/avatar.js
Outdated
| } | ||
|
|
||
| const svg = `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 80 80\">\n<rect width=\"100%\" height=\"100%\" rx=\"6\" ry=\"6\" fill=\"${ color }\"/>\n<text x=\"50%\" y=\"50%\" dy=\"0.36em\" text-anchor=\"middle\" pointer-events=\"none\" fill=\"#ffffff\" font-family=\"Helvetica, Arial, Lucida Grande, sans-serif\" font-size="50">\n${ initials }\n</text>\n</svg>`; | ||
| const svg = `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 80 80\">\n<rect width=\"100%\" height=\"100%\" fill=\"${ color }\"/>\n<text x=\"50%\" y=\"50%\" dy=\"0.36em\" text-anchor=\"middle\" pointer-events=\"none\" fill=\"#ffffff\" font-family=\"Helvetica, Arial, Lucida Grande, sans-serif\" font-size="50">\n${ initials }\n</text>\n</svg>`; |
Member
There was a problem hiding this comment.
when converting to png or jpeg the result image will have the viewBox size. is it 80x80 the size we would like it to have? just for reference, we're using a 120x120 image on profile detail.
sampaiodiego
approved these changes
Feb 14, 2018
Merged
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.
@RocketChat/core
Closes #7908
Add ability to request the placeholders in PNG or JPG formats passing a query string
format={png,jpg,jpeg}.Add ability to request the placeholders in any size smaller than 1024px passing a query string
format=jpg&size=80, default is 200pxExample https://open.rocket.chat/avatars/@rodrigo.nascimento?format=png&size=500