Posts: 6
Threads: 2
Joined: May 2012
On my site I allow users to create a profile and upload any image they wish to serve as their profile image. I'm wondering if there is a way to insert this user supplied image in place of the gravatar when users submit comments? Thanks.
Posts: 6
Threads: 2
Joined: May 2012
Okay, I was able to search around in the code and I've got this one figured out.
In the includes/functions folder, I modified the file comments.php as follows:
In place of
$box .= "<img src='http://www.gravatar.com/avatar/" . md5(strtolower(trim($email))) . ".png?s=71" . $gravatar_parameter . "' alt='Gravatar' title='Gravatar'/>";
I inserted
if (isset($_COOKIE['profile_image'])) {
$box .= "<img src='upload/profile_images/" . $_COOKIE['profile_image'] . "' alt='Profile Image' title='Profile Image' width='50' height='50' />";
} else {
$box .= "<img src='http://www.gravatar.com/avatar/" . md5(strtolower(trim($email))) . ".png?s=71" . $gravatar_parameter . "' alt='Gravatar' title='Gravatar'/>";
}
On login to my site, I store the profile image (if there is one) in a cookie. For users that haven't uploaded a profile image, the default gravatar will show up, or the gravatar stored at gravatar.com if they happen to have a gravatar tied to the email address on file with my site.
Posts: 6
Threads: 2
Joined: May 2012