DEV Community

Supraja Tangella
Supraja Tangella

Posted on

𝗗𝘆𝗻𝗮𝗺𝗶𝗰 𝗣𝗿𝗼𝗳𝗶𝗹𝗲 𝗣𝗶𝗰𝘁𝘂𝗿𝗲 𝗛𝗮𝗻𝗱𝗹𝗶𝗻𝗴 𝗶𝗻 𝗔𝗦𝗣.𝗡𝗘𝗧 𝗖𝗼𝗿𝗲 – 𝗪𝗶𝘁𝗵 𝗜𝗻𝗶𝘁𝗶𝗮𝗹𝘀 𝗙𝗮𝗹𝗹𝗯𝗮𝗰𝗸!

🚀 Today’s feature added to my 𝗝𝗼𝗯 𝗔𝗽𝗽𝗹𝗶𝗰𝗮𝘁𝗶𝗼𝗻 𝗧𝗿𝗮𝗰𝗸𝗲𝗿 project:

📸 𝗣𝗿𝗼𝗳𝗶𝗹𝗲 𝗜𝗺𝗮𝗴𝗲 𝗨𝗽𝗹𝗼𝗮𝗱 + 𝗗𝗶𝘀𝗽𝗹𝗮𝘆 𝘄𝗶𝘁𝗵 𝗙𝗮𝗹𝗹𝗯𝗮𝗰𝗸 𝗜𝗻𝗶𝘁𝗶𝗮𝗹𝘀!

👣 𝗦𝘁𝗲𝗽𝘀 𝗜 𝗳𝗼𝗹𝗹𝗼𝘄𝗲𝗱:

  1. If a user uploads an image, save it in wwwroot/images/ and store the path in ProfilePicImagePath.

  2. On login, display it using:

Avatar

  1. If no image is provided, generate a 𝗱𝘆𝗻𝗮𝗺𝗶𝗰 𝗶𝗺𝗮𝗴𝗲 𝘄𝗶𝘁𝗵 𝗶𝗻𝗶𝘁𝗶𝗮𝗹𝘀 (like "MC" for 𝗠𝗼𝘂𝗻𝗶𝗸𝗮 𝗖𝗛) using the full name. I used a fallback logic that:
    • Extracts initials from the name
    • Renders them onto a colored background using System.Drawing or ImageSharp
    • Saves the generated image and serves it in place of missing photos

🧠 𝗛𝗼𝘄 𝗱𝗼 𝘆𝗼𝘂 𝗽𝗿𝗲𝗳𝗲𝗿 𝘁𝗼 𝗵𝗮𝗻𝗱𝗹𝗲 𝗱𝗲𝗳𝗮𝘂𝗹𝘁 𝗽𝗿𝗼𝗳𝗶𝗹𝗲 𝗶𝗺𝗮𝗴𝗲𝘀 — 𝗴𝗲𝗻𝗲𝗿𝗮𝘁𝗲𝗱 𝗶𝗻𝗶𝘁𝗶𝗮𝗹𝘀 𝗼𝗿 𝗴𝗲𝗻𝗲𝗿𝗶𝗰 𝗮𝘃𝗮𝘁𝗮𝗿𝘀?

Top comments (0)