System Avatar Letter Color

In the user_avatars table, we can reverse engineer the link to a student’s custom avatar or gravatar via the fields custom_upload_id or gravatar_upload_id.
E.g. https://sjc3.discourse-cdn.com/business7/user_avatar/<discourse_url>/<username>/<img_size>/<upload_id>_2.png

When a user doesn’t have an avatar uploaded, they are auto assigned an avatar that looks like this:
https://avatars.discourse.org/v4/letter/g/d78d45/64.png

In this case, the structure of the link looks like this:
https://avatars.discourse.org/v4/letter/<letter_to_display>/<background_color_hex>/<img_size>.png

It’s clear by the link structure of the example above how to reconstruct the link. However, the one piece that I still can’t figure out is where the background_color_hex is stored in the database.

If anyone can help me out, I’d greatly appreciate it!

It’s calculated dynamically by the web server process based on a hash of the username.

2 Likes

Thanks @riking,

Any insights on how to replicate this process? Or can you suggest a different method to programmatically access a users avatar?

G