Fix Default Avatar Fallback (Param: default
vs url
)
#281
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.
Description of the Change
In #278, we fixed 2 issues as discussed on the slack but there is one more scenario we should handle.
Solution in this PR: The
default
parameter should be used only when the default avatar is set from the Media Library images.Technically, we utilize the
url
parameter to establish the default (fallback) avatar when the "Local only" setting is enabled, and we use thedefault
parameter when it's disabled. However, when it's disabled and, for instance, the RoboHash option is selected as the default avatar, WordPress core invariably checks for theurl
parameter and finds it empty, thus defaulting to the Gravatar logo as reported, bypassing the avatar set via thedefault
parameter.We have now realized that this is a complex flow because we introduced an option to select an actual image from the media library since #96. However, WordPress core is configured to utilize default avatars based solely on their respective names (e.g., mystery, blank, retro), taking these strings in the
default
parameter. Now, after #96, we must pass the full image URL indefault
, which has added complexity to this flow and requires careful handling. Ultimately, with this PR, we're appropriately (and hopefully) managing all scenarios with multiple conditions and utilizing thedefault
versusurl
parameter according to the settings.Closes https://wordpress.org/support/topic/gravatar-avatars-not-working/page/2/#post-17754560
How to test the Change
Changelog Entry
Credits
Props @faisal-alvi
Checklist: