This is the community forum. For a developer response use the Client Area.
Follow us on Facebook, Twitter and YouTube!

Gravatar > User supplied image
#1

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.
Reply
#2

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.
Reply
#3

Reply


Possibly Related Threads…
Thread / Author Replies Views Last Post
Last Post by msp
09-Jan-2016, 01:32 AM
Last Post by Things
10-Jun-2014, 10:48 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)