[wp-trac] [WordPress Trac] #37773: Update get_avatar() to support native and registered image sizes.
WordPress Trac
noreply at wordpress.org
Fri Jul 28 16:23:29 UTC 2017
#37773: Update get_avatar() to support native and registered image sizes.
-------------------------------------------------+-------------------------
Reporter: jmichaelward | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting
Component: Media | Review
Severity: normal | Version: 2.5
Keywords: has-patch has-unit-tests needs- | Resolution:
testing reporter-feedback dev-feedback | Focuses:
-------------------------------------------------+-------------------------
Comment (by jmichaelward):
@desrosj So, first, a little background on this ticket: I was working on
some updates for a plugin developed by my last employer that allows users
to upload a custom user profile photo. We had written a custom method that
users would call to output that image, and I'd felt that seemed
unnecessary when we can simply filter get_avatar inside of our plugin, and
instruct them to use the native WordPress method inside of their themes
(which also means they will not receive fatal errors when deactivating the
plugin, should they have called the method without a function_exists
check).
With regard to Gravatar's square imagery, it appears that I had accounted
for the square imagery returned by the service. In the patch, if a user
requests a non-square WordPress image size (e.g., medium, large, or
something custom), get_avatar will check if the requested size is
registered, get the register image size's dimensions, then set the size to
the greater of height or width.
I see now that this solution is half-baked. The user may not be expecting
a square image, and they may not be expecting the larger of the two
dimensions to be used. I do see that get_avatar sets some defaults for
height and width, so your recommendation for pre_get_avatar may already
address this.
In my view, a call to get_avatar should:
1. Allow the user to retrieve an image from non-Gravatar services (for
example, the WordPress media library)
2. Allow them to have a non-square profile image
I'm going to play around with this code some more and see if I can address
this using pre_get_avatar, per your recommendation, and then also check
whether it's possible to support passing a string for the image size as my
previous patch does.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/37773#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list