Skip to content

✨ Added member.avatar_image for member gravatar usage in front-end#11584

Merged
kevinansfield merged 4 commits into
TryGhost:masterfrom
kevinansfield:member-gravatar
Feb 19, 2020
Merged

✨ Added member.avatar_image for member gravatar usage in front-end#11584
kevinansfield merged 4 commits into
TryGhost:masterfrom
kevinansfield:member-gravatar

Conversation

@kevinansfield

@kevinansfield kevinansfield commented Feb 10, 2020

Copy link
Copy Markdown
Member

refs https://github.com/TryGhost/Team/issues/243

  • uses member.toJSON() to add a computed avatar_image property
    • if the member has an email address and gravatar is not disabled then we generate a gravatar url using the ?d=blank parameter to return a transparent image if the member's email has no gravatar

TODO:

  • review image location - /content/images/members/avatar/default/ was originally chosen because it would allow fallback for individual member images using the UUID but that's not necessary because member.avatar_image can be set directly to an uploaded image URL if one exists
  • review usage of version query param (Gravatar docs RE the ?d= param states "MUST NOT include a querystring (if it does, it will be ignored)")
    • dropped concept of fallback images in favour of gravatar's built-in transparent image
  • tests

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

oh! nice use of destructuring 💯

@kevinansfield
kevinansfield force-pushed the member-gravatar branch 5 times, most recently from 686ec2e to 52303fd Compare February 16, 2020 22:54
… image

refs TryGhost/Product#243

- adds `hasFile()` method to active theme object to give other parts of the system easier fallback behaviour if an override file does not exist in the them
- uses `member.toJSON()` to add a computed `avatar_image` property
  - starts with our "default" member avatar file that lives at `/content/images/members/avatar/default/`
  - attaches a version hash to more effectively clear caches when themes are updated
  - if the member has an email address and gravatar is not disabled then we generate a gravatar url using the `?d=` parameter that points to our default image location
- adds a new middleware for dealing with member avatars to the `site` app
  - responds to `/content/images/members/avatar/default/` by serving
    1. `assets/default-member-avatar.png` from the active theme
    2. `public/default-member-avatar.png` from core
- moved default avatar url to `{site}/assets/default-member-avatar.png`
- use `servePublicFile` middleware after the `staticTheme` middleware as a simpler fallback to the default public image if the theme asset image doesn't exist
- dropped specialised member avatar middleware and now-unused `ActiveTheme.hasFile` method
@kevinansfield kevinansfield changed the title ✨ Added member.avatar_image for gravatar with customisable fallback image ✨ Added member.avatar_image for member gravatar usage in front-end Feb 17, 2020
@kevinansfield
kevinansfield marked this pull request as ready for review February 17, 2020 14:15
@kevinansfield
kevinansfield requested review from daniellockyer, naz and rshbhgrg and removed request for daniellockyer, naz and rshbhgrg February 19, 2020 10:07
@kevinansfield
kevinansfield merged commit 19812f5 into TryGhost:master Feb 19, 2020
@kevinansfield
kevinansfield deleted the member-gravatar branch February 19, 2020 10:09
peterzimon added a commit to TryGhost/Lyra that referenced this pull request Feb 19, 2020
refs:
TryGhost/Product#243
TryGhost/Ghost#11584

- uses `@member.avatar_image` attribute to show Gravatars on account page and site navigation
- falls back to theme's default avatar icon if logged in member doesn't have a Gravatar
daniellockyer added a commit that referenced this pull request Feb 24, 2020
* master: (24 commits)
  Version bump to 3.8.0
  Updated Ghost-Admin to 3.8.0
  🐛 Fixed incorrect email count on post publish (#11616)
  Update dependency @sentry/node to v5.12.4
  Handled missing resource path for resized images
  Added migration to add members.geolocation
  Allowed editing member's email
  Added missing frame parameter in member mapper
  Added "trust proxy" to members API app
  Removed unused cpy-cli dependency
  Refactored variable name to match intent
  Fixed use of deprecated function in test suite
  Combined Ghost-CLI tests into one GitHub Action job
  Update dependency mysql to v2.18.1
  Added `created_at` field to accepted fields for members CSV import
  Fixed member API regression tests
  ✨ Added `member.avatar_image` for member gravatars in themes (#11584)
  Enabled full test suite on Renovate PRs
  Revert "Update dependency grunt-mocha-cli to v5"
  Update dependency grunt-mocha-cli to v5
  ...
pull Bot pushed a commit to YashRajCodes/Ghost that referenced this pull request Jul 20, 2026
…t#11584)

refs TryGhost/Product#243

- uses `member.toJSON()` to add a computed `avatar_image` property
  - if the member has an email address and gravatar is not disabled then we generate a gravatar url using the `?d=blank` parameter to return a transparent image if the member's email has no gravatar
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