Changing the default ui-avatars.com colors

How would I go about changing the color scheme of the default ui-avatars? We are currently using background=0D8ABC&color=fff for our users and would like to match that for the default ui-avatar. Currently getting around it this way. But is this the correct way of doing it?
public function getFilamentAvatarUrl(): ?string
{
return $this->avatar_url
? Storage::disk('profile-photos')->url($this->avatar_url)
: 'https://ui-avatars.com/api/?background=0D8ABC&color=fff&name='.urlencode($this->name);
}
public function getFilamentAvatarUrl(): ?string
{
return $this->avatar_url
? Storage::disk('profile-photos')->url($this->avatar_url)
: 'https://ui-avatars.com/api/?background=0D8ABC&color=fff&name='.urlencode($this->name);
}
3 Replies
Dennis Koch
Dennis Koch4w ago
You could also use a AvatarProvider (https://filamentphp.com/docs/3.x/panels/users#using-a-different-avatar-provider) but if your solution works, why not?
Dennis Koch
Dennis Koch4w ago
Nothing bad with your appraoch I guess
Batman
BatmanOP4w ago
@Dennis Koch I have considered the AvatarProvider approach. Seemed a bit overkill for this particular situation, but I could definitely see going that route and having a config to easily change colors.

Did you find this page helpful?