Make WordPress Core

Opened 10 months ago

Closed 8 months ago

Last modified 3 months ago

#63087 closed enhancement (fixed)

Make the Default Avatar support Gravatar's newly added Initials Avatars and Color Avatars

Reported by: haozi's profile haozi Owned by: audrasjb's profile audrasjb
Milestone: 6.9 Priority: normal
Severity: normal Version:
Component: Users Keywords: has-patch
Focuses: Cc:

Description

Gravatar added Initials Avatars and Color Avatars last month, and I thought we could integrate them into WordPress. Like the other default avatar types.

Gravatar blog post: https://blog.gravatar.com/2025/02/19/initials-avatars-email-signatures/
Gravatar API documentation: https://docs.gravatar.com/api/avatars/images/

Change History (13)

#1 @haozi
10 months ago

Here:

https://s2.loli.net/2025/03/12/dLTVwqvhlUAXm1Z.png

This ticket was mentioned in PR #8498 on WordPress/wordpress-develop by @sukhendu2002.


10 months ago
#2

  • Keywords has-patch added

@haozi commented on PR #8498:


10 months ago
#3

https://github.com/user-attachments/assets/2fbe77f0-ec38-4f37-aa0e-8c6fc62d8a65

Good job, I can test it in playground.

This ticket was mentioned in Slack in #core by haozi. View the logs.


8 months ago

#5 @audrasjb
8 months ago

  • Milestone changed from Awaiting Review to 6.9
  • Owner set to audrasjb
  • Status changed from new to accepted
  • Version trunk deleted

#6 @audrasjb
8 months ago

Previously: #57493

@getsyash commented on PR #8498:


8 months ago
#7

https://github.com/user-attachments/assets/cd540c1b-2574-4675-9662-a89c1976a3ab
Working fine on playground

@valentingrenier commented on PR #8498:


8 months ago
#8

Also tested on Playground with version 6.8-beta2.

Steps done:

  • Settings > Discussion > Default Avatar > "Initials (Generated)" and "Colors (Generated)" available
  • Users > Profile > Profile Picture is updated

Working as expected ✅

https://github.com/user-attachments/assets/65b8434d-a026-45a6-a2ba-1d904a0dcd35
https://github.com/user-attachments/assets/f267914f-e010-4559-8e92-576cea54af59

#9 @audrasjb
8 months ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 60269:

Users: Add support for Initials and Color Gravatar images in default user profile pics.

Gravatar includes support for Initials and Color auto-generated images. This changeset adds them to the built-in feature for user profile images.

Props haozi, audrasjb, getsyash, valentingrenier.
Fixes #63087.
See #57493.

#10 @SergeyBiryukov
3 months ago

In 60897:

Coding Standards: Simplify the initials avatar type handling in get_avatar_data().

Includes:

  • Converting a long ternary to an if/elseif block for better readability.
  • Reusing an existing translatable string for user's first name and last name.
  • Replacing empty() checks with more specific checks for an empty string.
  • Replacing is_object() check with a check for a WP_Comment instance.

Follow-up to [53501], [60269].

See #63087.

#11 follow-up: @TobiasBg
3 months ago

@SergeyBiryukov: The false === strpos( $name, ' ' ) in [60897] could be made more readable with ! str_contains( $name, ' ' ), I think?

#12 in reply to: ↑ 11 @SergeyBiryukov
3 months ago

Replying to TobiasBg:

The false === strpos( $name, ' ' ) in [60897] could be made more readable with ! str_contains( $name, ' ' ), I think?

Ah yes, thanks :)

#13 @SergeyBiryukov
3 months ago

In 60900:

Code Modernization: Use str_contains() in get_avatar_data().

str_contains() was introduced in PHP 8.0 to perform a case-sensitive check indicating if the string to search in (haystack) contains the given substring (needle).

WordPress core includes a polyfill for str_contains() on PHP < 8.0 as of WordPress 5.9.

Follow-up to [52039], [55988], [56245], [60897].

Props TobiasBg.
See #63087.

Note: See TracTickets for help on using tickets.