Skip to content

Omit the Gravatar d parameter for gravatar_default - #274

Merged
lancewillett merged 1 commit into
masterfrom
fix/o2-gravatar-default
Nov 4, 2026
Merged

lancewillett merged 1 commit into
masterfrom
fix/o2-gravatar-default

Conversation

@lancewillett

@lancewillett lancewillett commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Bug fix

JavaScript change in two avatar URL builders, plus QUnit tests.

When a site's avatar_default option is gravatar_default, o2 builds Gravatar URLs with d=gravatar_default. That is not a Gravatar default ID. WordPress core treats the value as the Gravatar logo and leaves d out (get_avatar_data() in wp-includes/link-template.php). o2 now does the same:

  • getUserFor() in js/collections/users.js
  • onBlurCommentorEmail() in js/views/comment.js

Other default values, such as identicon and mystery, still send d.

Rationale

o2 should send the same avatar URL WordPress core sends, rather than relying on Gravatar to accept a value it does not define. WordPress.com's two copies of o2 get the same change.

Testing this change

  • npx grunt qunit passes. The two new tests in tests/qunit/avatars.js fail on master at the gravatar_default assertions.
  • npx grunt lint passes.
  • In a wp-env site with p2-breathe, o2 enabled and avatar_default set to gravatar_default, the o2-rendered avatars have no d. On master they end in ?d=gravatar_default.
  • With avatar_default set to identicon, the avatars still end in ?d=identicon.

The logged-out comment form template adds &s= to the avatar URL. With gravatar_default it now renders https://gravatar.com/avatar/&s=32. Gravatar returns the same logo for it, at the default 80px instead of 32px, which the <img> width and height scale down.

Definition of done

  • Both builders omit d for gravatar_default
  • Other default values keep d
  • New QUnit tests fail without the fix and pass with it
  • CI green
  • Reviewed

🤖 Generated with Claude Code

When a site's avatar_default option is gravatar_default, o2 built
Gravatar URLs with d=gravatar_default, which is not a Gravatar default
ID. WordPress core treats this value as the Gravatar logo and leaves d
out. Do the same in getUserFor() and onBlurCommentorEmail(), and add
QUnit coverage for both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lancewillett
lancewillett requested a review from bor0 November 4, 2026 16:45
@lancewillett
lancewillett merged commit a5d6044 into master Nov 4, 2026
3 checks passed

@bor0 bor0 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, matches core's get_avatar_data(). One small thing: logged-out-create-comment.php appends &s= to the URL, so with gravatar_default you get avatar/&s=32 and the 80px logo. With a real hash, <hash>&s=32 returns the Gravatar logo instead of the person's avatar, so it might be worth having the template choose ? or & now.

lancewillett added a commit that referenced this pull request Nov 4, 2026
The logged-out comment form template appends `&s=` to the avatar URL.
Since #274, a gravatar_default site's avatar URL has no `?`, so the
size lands in the path and Gravatar serves the default 80px image.
Always keep the `?`, and test the URL the template builds.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants