Skip to content

Keep the query string on avatar URLs for gravatar_default - #275

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

lancewillett merged 1 commit into
masterfrom
fix/o2-gravatar-avatar-query

Conversation

@lancewillett

@lancewillett lancewillett commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Bug fix

JavaScript change in getUserFor(), plus an updated QUnit test. Follow-up to #274.

The logged-out comment form template, inc/tpl/logged-out-create-comment.php, appends &s= to the avatar URL that getUserFor() builds. Since #274, a site with avatar_default set to gravatar_default gets an avatar URL with no ?, so the size lands in the URL path:

  • Before: https://gravatar.com/avatar/&s=32. Gravatar returns its 80px default image, which the <img> scales down.
  • After: https://gravatar.com/avatar/?&s=32. Gravatar returns the 32px image.

getUserFor() now always adds the ? and only leaves out d=. Other defaults are unchanged.

Rationale

Code may append parameters to this URL, and with no ? the first & lands in the path. Keeping the ? makes appended parameters work the same for every default.

Testing this change

  • npx grunt qunit passes. The getUserFor test now checks the URL the template builds, and it fails on master.
  • npx grunt lint passes.
  • In a wp-env site with p2-breathe, o2 enabled and avatar_default set to gravatar_default, the logged-out comment form renders https://gravatar.com/avatar/?&s=32. On master it renders https://gravatar.com/avatar/&s=32.
  • With avatar_default set to identicon, the form renders https://gravatar.com/avatar/?d=identicon&s=32.

Definition of done

  • The logged-out form keeps s in the query string for gravatar_default
  • Other defaults keep d
  • The updated test fails without the fix
  • CI green

🤖 Generated with Claude Code

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>
@lancewillett
lancewillett merged commit 344985f into master Nov 4, 2026
3 checks passed
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.

1 participant