[wp-trac] [WordPress Trac] #37773: Update get_avatar() to support native and registered image sizes.

WordPress Trac noreply at wordpress.org
Fri Jul 28 20:23:46 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):

 After some further consideration, I think it may be acceptable to allow a
 user to pass a registered WordPress image size and have it revert to a
 square Gravatar image if pre_get_avatar is not filtered, so long as we
 document what developers can expect in this case. This latest patch will
 set the size of the Gravatar image to the height of the registered
 WordPress image size (squared) in the event that pre_get_avatar is not
 filtered.

 These changes will allow developers to filter pre_get_avatar to return
 non-square avatars using native WordPress registered image sizes. It
 accounts for custom image sizes as well, so if a theme registers its own
 avatar thumbnail, the developers can call `<?php get_avatar( $user_id,
 'my-custom-avatar-thumbnail' ); ?>` and expect to get the correct
 registered image size.

 Additional unit tests are needed, but I think this is on the right path.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/37773#comment:10>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list