3 ms·
Nice service - I was looking for something like this to generate default avatars for our SaaS app recently. How does it handle middle names? i.e., does "John A
by cyberferret 9y ago
Nice service - I was looking for something like this to generate default avatars for our SaaS app recently.
How does it handle middle names? i.e., does "John Arthur Smith" still return (JS)? What about reverse names, e.g. "Smith, John Arthur"? Is it smart enough to parse the comma and work out first/last initials from that?
Addendum: I also assume that you intend this service to be a 'once off' generation of a user avatar which can be stored locally? Do you rate limit so that people cannot simply dynamically generate avatars for ridiculous long lists of people on their web page?
- amyboyd 9y agoJust tried it -- by default it renders the first and third initial: https://ui-avatars.com/api/?name=John+Doe+Third https://ui-avatars.com/api/?name=John+Doe+Third You can add "&length=3" to the query string and it will render all three initials: https://ui-avatars.com/api/?name=John+Doe+Third&length=3 https://ui-avatars.com/api/?name=John+Doe+Third&length=3
- lasserafn 9y agoThank you! It handles last names and middle names as such: - your example would be JS, however if you specify a desired length of 3, it would be: JAS. I actually haven’t tested commas and such but I will definitively add this! Added it to my todo
- cyberferret 9y agoBrilliant - thanks for this. Also, would be a nice feature to have the colours randomise themselves as an option, so that I could have different coloured avatars on my people listing without having to worry about generating pleasing colours and ensuring that the foreground and background do not clash.
- lasserafn 9y agoIt's funny you'd say this! I remember when I launched the core package on Github, someone suggested colors to be generated from the name or initials. I will look into this, it would be pretty neat! Thanks for the feedback :-)
- williamdclt 9y agoI'd say random is better than generated from initials, to avoid two persons with same initials having the same avatar! Random with font color depending on background color (so it's readable and pretty) would be even better :)
- lasserafn 9y agoI love the idea! It's added to my todo :D
- lasserafn 9y agoUt stores the avatars on the server, cached by all parameters (not the name, but the generated initials) to avoid generating them again. Also some response headers are set to ask browsers to cache the response. I would also recommend users of this to download the avatars, as you suggested, especially to ensure fastest possible response rates. Actually there is no rate limiting, but seeing just how many visitors this HN post has gotten, I may have to add some sort of limiting. I haven't really figured exactly what I'm going to do regarding limiting and servers. Currently I'm setting up servers in each region my provider supports, to fix latency issues, and spread the load