-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Add x2 to url string that defines the image size by default #39728
Conversation
Size Change: +35 B (0%) Total Size: 1.21 MB
ℹ️ View Unchanged
|
Nice! This works well. Shown here, 96px does render the double size, ensuring always crispness. It isn't entirely visible as I resize in this GIF because the GIF is 1x resolution, but it works: While you'r in here, can you change the panel to just say "Settings"? Avatar is implied by the text above: Not something for this PR, but the spacing between the User label/input/helptext and the toggle below is a bit tight: On the component side, do we have any tricks here, @ciampo? |
ef3870d
to
b3625c4
Compare
Nice! Because the code is a bit foreign to me, I'd appreciate a quick code review. But visually this is in much better shape. Thank you! 👍 👍 |
Let's wait for a code review then. I'm also not sure if there could be a better approach to this. |
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.
Looks good to me! 👍
My only concern was that removing the s
and then adding it back to the query string re-orders the params, but I don't see a reason why it would matter here 🙂
Sorry for the late response @jasmussen, I was AFK in the past days! I'll still leave an answer in case we want to follow-up to the changes in this PR. As of today, we have: |
What?
Increase the size of the Avatar image to be 2x of the width chosen, in order not to get pixelated on retina displays.
Why?
Right now, WordPress by default has 3 sizes for the User Avatars:
With the new Avatar block, we allow the user up to 240px size. Causing all Avatars above 96px will get pixelated. Also, all Avatars above 48px will get pixelated on retina displays.
How?
Behind the scenes, it calls Gravatar URLs for defaults Avatars as well for custom Avatars based on user emails. Some similar to this:
http://1.gravatar.com/avatar/d7a973c7dab26985da5f961be7b74480?s=96&d=mm&r=g
If we check the URL, the query
s
defines the image size ->?s=96
It seems that just by doubling that value, Gravatar will return an image of that size. So we can double it both in the editor and in the frontend (the
wp_get_avatar()
function is adding thesrcset
attribute with a 2x by default).Testing Instructions
Screenshots or screencast
Editor with a 165*2 size:

Frontend with a 165 size for srcset 1x, a 165*2 for srcset2x
