Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gravatarImageUrlToGravatarImageUrl to utils + minor improvements #38

Merged
merged 10 commits into from
Jan 26, 2024

Conversation

maxme
Copy link
Contributor

@maxme maxme commented Jan 24, 2024

Main goal of this PR is to add a new gravatarImageUrlToGravatarImageUrl function.

Why adding this function here? Well, I think this can be a common pattern for other developers, not just for WordPress:

  • developers store the avatar image url on their backend and returns the urls in their API.
  • this API is used in mobile apps, thus they get the avatar image urls directly (instead of constructing them from email adresses).
  • mobile apps might require to resize the avatar image to show them in different context (list view, full profile, etc), and to do that, they can leverage the gravatar backend by passing the right size parameter. Same for placeholder images, in some context we might want to show the default image, but in some other context we might want to provide the app's placeholder image (in that case, using the STATUS_404 default image might be a great use).

When we start writing documentation, we should provide examples of this one, but I'm not sure we should push for it.

This PR also:

@maxme maxme force-pushed the maxime/new-gravatar-url-rewriting-utils branch from 3927fa5 to 55ad795 Compare January 25, 2024 08:48
@maxme maxme changed the title Draft: add gravatarImageUrlToGravatarImageUrl to utils + minor improvements Add gravatarImageUrlToGravatarImageUrl to utils + minor improvements Jan 25, 2024
@maxme
Copy link
Contributor Author

maxme commented Jan 25, 2024

Note: I'm open to suggestions to rename gravatarImageUrlToGravatarImageUrl:

  • rewriteGravatarUrl
  • rewriteGravatarImageUrl
  • rewriteGravatarUrlQueryParams
  • rewriteGravatarImageUrlQueryParams seems more precise but is quite long.

@hamorillo hamorillo self-requested a review January 25, 2024 11:18
Copy link
Contributor

@hamorillo hamorillo left a comment

Choose a reason for hiding this comment

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

❤️ Nice work @maxme! I love the amount of unit tests you added.

I left some comments, but they are all non-blocking.

@maxme maxme force-pushed the maxime/new-gravatar-url-rewriting-utils branch 2 times, most recently from a0fb760 to fc91874 Compare January 25, 2024 16:04
@maxme
Copy link
Contributor Author

maxme commented Jan 25, 2024

@hamorillo, it should be good to go as I integrated all your comments, but better do a second pass.

@maxme maxme force-pushed the maxime/new-gravatar-url-rewriting-utils branch from fc91874 to 2eb0adc Compare January 26, 2024 07:49
Copy link
Contributor

@hamorillo hamorillo left a comment

Choose a reason for hiding this comment

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

❤️ Great job! 🚀

@maxme maxme merged commit 891395c into trunk Jan 26, 2024
2 checks passed
@maxme maxme deleted the maxime/new-gravatar-url-rewriting-utils branch January 26, 2024 09:34
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.

Add missing options to default image Add more query params to Gravatar URL generation
2 participants