NOTE: This is hobby project only
******************************************************************************
MOTIVATION: Didn't want to write code on
backend which would run every time to generate this placeholer/named icon.
The Single and Double character combination is only available because
it satisfies my current needs
******************************************************************************
Generate and get named placeholder icon
Just put your single or double character on.
Currently only accepts single or double character Uppercase A-Z alphabet combination
| URL | Output |
|---|---|
| https://icon.prodconfig.com/icon/50/A.png | |
| https://icon.prodconfig.com/icon/50/DY.png |
def create_named_icon_url(text):
split_text = text.split()
if len(split_text) > 1:
letters = [x[0] for x in split_text]
_r = "".join(letters)[:2]
else:
_r = split_text[0][:2]
return f"https://icon.prodconfig.com/icon/50/{_r.upper()}.png"
create_named_icon_url(text="Hello World") # ==> https://icon.prodconfig.com/icon/50/HW.png
create_named_icon_url(text="John ABC Xyz") # ==> https://icon.prodconfig.com/icon/50/JA.png