# System Avatar Letter Color

**URL:** https://meta.discourse.org/t/system-avatar-letter-color/129696
**Category:** Support
**Created:** [September 27, 2019, 8:18pm UTC](https://meta.discourse.org/t/system-avatar-letter-color/129696 "2019-09-27T20:18:42Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Grayden\_Shand](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/grayden_shand/32/166586_2.png) [@Grayden\_Shand](https://meta.discourse.org/u/Grayden_Shand)
#### Post date: [September 27, 2019, 8:18pm UTC](https://meta.discourse.org/t/system-avatar-letter-color/129696/1 "2019-09-27T20:18:42Z")

</div>

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`  
 ![](https://global.discourse-cdn.com/meta/original/3X/f/b/fbfc0ff5e799c30ed4e30a35b2407d04c64ad2cf.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!

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [September 28, 2019, 6:22pm UTC](https://meta.discourse.org/t/system-avatar-letter-color/129696/2 "2019-09-28T18:22:02Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Grayden\_Shand](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/grayden_shand/32/166586_2.png) [@Grayden\_Shand](https://meta.discourse.org/u/Grayden_Shand)
#### Post date: [September 29, 2019, 1:45pm UTC](https://meta.discourse.org/t/system-avatar-letter-color/129696/3 "2019-09-29T13:45:47Z")

</div>

Thanks @riking,

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

G

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [May 23, 2023, 11:16pm UTC](https://meta.discourse.org/t/system-avatar-letter-color/129696/4 "2023-05-23T23:16:19Z")

</div>



---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [July 3, 2023, 11:52am UTC](https://meta.discourse.org/t/system-avatar-letter-color/129696/5 "2023-07-03T11:52:35Z")

</div>


