Generating Random Avatars with Multiavatar API in PHP
The article explains how to discover the Multiavatar service, use browser developer tools to modify the MD5 hash in the URL to obtain different avatars, and provides a concise PHP function that returns a random avatar URL based on an email address.
While browsing, the author discovered a website that can generate random avatars (www.atoolbox.net/Tool.php?Id=1013) and later identified the actual service at https://multiavatar.com/ with a unique MD5 hash in the URL.
Using the browser's developer tools, they observed that changing the MD5 part of the URL produces different avatar images, confirming the generation mechanism.
Based on this insight, a simple PHP helper function is provided, which computes the MD5 hash of an email address and returns the corresponding Multiavatar PNG URL.
if (!function_exists('make_avatar')) {
function make_avatar($email)
{
$md5_email = md5($email);
return "https://api.multiavatar.com/{$md5_email}.png";
}
}This function enables developers to easily obtain a random avatar for any user without external dependencies.
php中文网 Courses
php中文网's platform for the latest courses and technical articles, helping PHP learners advance quickly.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.