How can Gravatars be implemented as an alternative to user-uploaded profile pictures on a website?

To implement Gravatars as an alternative to user-uploaded profile pictures on a website, you can use the Gravatar API to fetch the user's Gravatar based on their email address. This allows for a consistent and universally recognizable avatar across different websites and platforms.

<?php
function get_gravatar_url($email, $size = 80) {
    $hash = md5(strtolower(trim($email)));
    return "https://www.gravatar.com/avatar/$hash?s=$size";
}

$email = "user@example.com";
$avatar_url = get_gravatar_url($email);

echo "<img src='$avatar_url' alt='Gravatar'>";
?>