|
Gravatar > User supplied image
|
|
12-May-2012, 01:38 PM
Post: #1
|
|||
|
|||
|
Gravatar > User supplied image
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.
|
|||
|
12-May-2012, 03:37 PM
Post: #2
|
|||
|
|||
|
RE: Gravatar > User supplied image
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. |
|||
|
13-May-2012, 02:11 PM
Post: #3
|
|||
|
|||
|
RE: Gravatar > User supplied image
!!ERROR!! - I discovered that the code I amended yesterday will insert the currently logged-in user profile image for virtually every user comment, so I had to do a little more work to get this right.
All of the following amends the comments.php file located in the includes/functions folder. PHP Code: if (!defined("IN_COMMENTICS")) { die("Access Denied."); } //This line exists in the original comments.php file, insert code amendments belowThen, in place of this: PHP Code: $box .= "<img src='http://www.gravatar.com/avatar/" . md5(strtolower(trim($email))) . ".png?s=71" . $gravatar_parameter . "' alt='Gravatar' title='Gravatar'/>"; Insert this: PHP Code: $theprofileimg = GetProfileImg($name,$_SESSION['mylink']);With this revision, I no longer have to store the users profile image in a cookie upon login. I prefer to minimize the use of cookies, so for me this is a good thing. Thanks. Skilife |
|||
|
« Next Oldest | Next Newest »
|
| Possibly Related Threads... | |||||
| Thread: | Author | Replies: | Views: | Last Post | |
| Tanya Cara menampilkan coment user dan admin di halaman customer | upenx | 4 | 729 |
05-Jun-2012 07:43 AM Last Post: upenx |
|
| get the User name and email from db | Abdul | 6 | 760 |
14-Apr-2012 03:48 PM Last Post: Steven |
|
User(s) browsing this thread: 1 Guest(s)

Search
Member List
Calendar
Help



