4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Releases & Support) => Topic started by: Lucifix on January 29, 2009, 09:36:49 AM

Title: [MOD] User Gravatars
Post by: Lucifix on January 29, 2009, 09:36:49 AM
Description:
This simple MOD will add Gravatars in user comments, based on their 4images registered email and registration on Gravatar website: http://en.gravatar.com/

Screenshot:
(http://img206.imageshack.us/img206/9481/gravatarsgz8.jpg) (http://imageshack.us)

What are Gravatars?
A gravatar, or globally recognized avatar, is quite simply an avatar image that follows you from blog to blog appearing beside your name when you comment on gravatar enabled sites. Avatars help identify your posts on web forums, so why not on blogs? (in our case 4images gallery):)
More: http://en.gravatar.com/

How to do it?
1.
- open templates/[your template folder]/comment_bit.html
- search:
Code: [Select]
<b>{comment_user_name}</b><br />
- after add:
Code: [Select]
{comment_user_gravatar}<br />
2.
- open details.php
- search:
Code: [Select]
$comment_user_ip = ($user_info['user_level'] == ADMIN) ? $comment_row[$i]['comment_ip'] : "";
- after add:
Code: [Select]
  $default_size = "50"; // width/height of avatars
  $default_rating = "G"; // An optional rating parameter may follow with a value of [ G | PG | R | X ] which determines the highest rating (inclusive) that will be returned.
      $md5 = md5( strtolower( $comment_row[$i][$user_table_fields['user_email']] ) );
  $comment_user_gravatar = "<img src='http://www.gravatar.com/avatar.php?gravatar_id=$md5&amp;size=$default_size&amp;rating=$default_rating' width='$default_size' height='$default_size' alt='' />";

-search:
Code: [Select]
"comment_user_ip" => $comment_user_ip,
- after add:
Code: [Select]
"comment_user_gravatar" => $comment_user_gravatar,
That's it! Enjoy!  :wink:
Title: Re: [MOD] User Gravatars
Post by: flyfreak on March 15, 2009, 12:57:15 PM
Thanks!
Title: Re: [MOD] User Gravatars
Post by: V@no on March 15, 2009, 01:18:49 PM
very nice! somehow I've missed this mod...
Just yesterday I learned about gravatar site, and thought it was a good and innovative idea/concept.


In addition, if you don't want to see gravatar icon if no avatar available, you can add:
&amp;default=path to default avatar image
at the end of image address.

i.e.:
Code: [Select]
$comment_user_gravatar = "<img src='http://www.gravatar.com/avatar.php?gravatar_id=$md5&amp;size=$default_size&amp;rating=$default_rating&amp;default=".$script_url."/".TEMPLATE_PATH."/images/user_online.gif' width='$default_size' height='$default_size' alt='' />";
Title: Re: [MOD] User Gravatars
Post by: flyfreak on March 15, 2009, 02:50:38 PM
But iīve got som problems with this mod:

Example: http://www.flyfreak.dk/foto/img173.htm?l=English
The Gravatar donīt show my avatar - and i know that my avatar works, because i had tested it on many wordpress sites.
Title: Re: [MOD] User Gravatars
Post by: Lucifix on March 15, 2009, 06:29:55 PM
Can you tell me what is your email? And the wordpress site where it shows your gravatar?
Title: Re: [MOD] User Gravatars
Post by: V@no on March 15, 2009, 08:33:10 PM
first of all, line:
  $md5 = md5( strtolower( $user_row_comment['user_email'] ) );


should be:
  $md5 = md5( strtolower( $comment_row[$i][$user_table_fields['user_email']] ) );


and second, my change above was incorrect. I've updated it with the correct one.
Title: Re: [MOD] User Gravatars
Post by: flyfreak on March 16, 2009, 07:31:09 AM
Can you tell me what is your email? And the wordpress site where it shows your gravatar?

http://www.larsbachmann.dk/velkommen-til-hvem-er-du.html
The comment from Emil at 17 January 2009 kl. 00:10




first of all, line:
  $md5 = md5( strtolower( $user_row_comment['user_email'] ) );


should be:
  $md5 = md5( strtolower( $comment_row[$i][$user_table_fields['user_email']] ) );


and second, my change above was incorrect. I've updated it with the correct one.

Thanks. I will try that
Title: Re: [MOD] User Gravatars
Post by: desperate_housewif on March 21, 2009, 09:56:29 AM
How can a user upload his image. It it possible directly in 4images, or must they turn into Gravatar.com to make there new gravatar?
Title: Re: [MOD] User Gravatars
Post by: V@no on March 21, 2009, 10:00:15 AM
Everything is done via gravatar.com
if you want users upload avatars directly to 4images, then you'll need install avatar mod.
Title: Re: [MOD] User Gravatars
Post by: flyfreak on April 07, 2009, 07:29:10 PM
How can i show the gravatar of an user in their profile?
Title: Re: [MOD] User Gravatars
Post by: flyfreak on April 09, 2009, 12:41:10 AM
bump
Title: Re: [MOD] User Gravatars
Post by: V@no on April 09, 2009, 04:14:08 AM
How can i show the gravatar of an user in their profile?
In member.php find:
Code: [Select]
      "user_email" => $user_email,

Insert below:
Code: [Select]
      "user_email_orig" => $user_row['user_email'],


In templates/<your template>/member_profile.html add:
Code: (template/HTML+PHP) [Select]
<?php
$default_size 
"50"// width/height of avatars
$default_rating "G"// An optional rating parameter may follow with a value of [ G | PG | R | X ] which determines the highest rating (inclusive) that will be returned. 
$md5 md5(strtolower("{user_email_orig}"));
?>

<img src="http://www.gravatar.com/avatar.php?gravatar_id=<?=$md5?>&amp;size=<?=$default_size?>&amp;rating=<?=$default_rating?>" width="<?=$default_size?>" height="<?=$default_size?>" alt="" />
Title: Re: [MOD] User Gravatars
Post by: flyfreak on April 15, 2009, 10:59:43 PM
Thanks a lot  :D - i will test it soon!
Title: Re: [MOD] User Gravatars
Post by: kremqun on July 05, 2009, 02:12:06 PM
Guys, can anyone tell me, how can i insert the gravatar of the image adder.
i mean in the section of {lang_added_by}{user_name_link}.
Title: Re: [MOD] User Gravatars
Post by: surferboy on April 08, 2010, 02:03:41 AM
Hi -

Was wondering if V@no's Avatar v2.01 would interfere with this MOD?  I saw his post in this topic string but was just wondering if we have a member who is a Gravatar user who then decides to upload another avatar on 4images if there would be a conflict, and also if he/she decides to unravel their personal avatar, if they can revert to the Gravatar once again.

Thanks for your thoughts.

Brian
Title: Re: [MOD] User Gravatars
Post by: V@no on April 08, 2010, 03:31:55 AM
In theory you can combine both mods using the same method as in my first reply.

i.e.
$comment_user_gravatar = "<img src='http://www.gravatar.com/avatar.php?gravatar_id=$md5&amp;size=$default_size&amp;rating=$default_rating&amp;default=".$script_url."/". TEMPLATE_PATH."/avatars/".(($user_row_comment['user_avatar'] == "") ? "blank.gif" : $user_row_comment['user_avatar']) . "' width='$default_size' height='$default_size' alt='' />";
Title: Re: [MOD] User Gravatars
Post by: surferboy on April 08, 2010, 05:46:52 AM
Hi -

I'm using v1.7.7

I have installed the MOD and tried to incorporate a default 50x50 default gif instead of the Gravatar icon, following V@no's code. Here is what I added in Details.php:

Quote
$comment_user_ip = ($user_info['user_level'] == ADMIN) ? $comment_row[$i]['comment_ip'] : "";
      $default_size = "50"; // width/height of avatars
      $default_rating = "X"; // An optional rating parameter may follow with a value of [ G | PG | R | X ] which determines the highest rating (inclusive) that will be returned.
      $md5 = md5( strtolower( $comment_row[$i][$user_table_fields['user_email']] ) );
      $comment_user_gravatar = "<img src='http://www.gravatar.com/avatar.php?gravatar_id=$md5&amp;size=$default_size&amp;rating=$default_rating&amp;default='http://www.domain.com/ourgallery/templates/default/images/imagename.gif' width='$default_size' height='$default_size' alt='' />";

Also, there are two locations where
Quote
"comment_user_ip" => $comment_user_ip,
appears.

I assumed it went in this section:

Quote
$site_template->register_vars(array(
        "comment_id" => $comment_row[$i]['comment_id'],
        "comment_user_id" => $comment_user_id,
        "comment_user_status_img" => $comment_user_status_img,
        "comment_user_name" => $comment_user_name,
        "comment_user_info" => $comment_user_info,
        "comment_user_profile_button" => $comment_user_profile_button,
        "comment_user_email" => $comment_user_email,
        "comment_user_email_save" => $comment_user_email_save,
        "comment_user_mailform_link" => $comment_user_mailform_link,
        "comment_user_email_button" => $comment_user_email_button,
        "comment_user_homepage_button" => $comment_user_homepage_button,
        "comment_user_icq_button" => $comment_user_icq_button,
        "comment_user_ip" => $comment_user_ip,
        "comment_user_gravatar" => $comment_user_gravatar,
        "comment_headline" => format_text($comment_row[$i]['comment_headline'], 0, $config['wordwrap_comments'], 0, 0),
        "comment_text" => format_text($comment_row[$i]['comment_text'], $config['html_comments'], $config['wordwrap_comments'], $config['bb_comments'], $config['bb_img_comments']),
        "comment_date" => format_date($config['date_format']." ".$config['time_format'], $comment_row[$i]['comment_date']),
        "row_bg_number" => $row_bg_number,
        "admin_links" => $admin_links

A user with a gravatar account was added to the gallery.  His gravatar immediately appeared on the member profile page but his Gravatar did not appear in the comment section when I logged in under his username and made a comment about an image that was posted by another user. Note that I have the MOD Show Received Comments V.2, topic 12695.0.  I believe this MOD is not the source of the problem but the cause of the updates from this MOD not appearing on my gallery. I have to say that I am so thankful that I have kept a record log of each MOD that I have done because I was able to see my notes on where I inserted the user_image in that MOD install which made me realize that this MOD is asking me to make changes to comment_bit.html when I should be making changes to member_comment_bit.htm.

Trying now and we'll see if that fixes the problem. Nope, that did not fix it although I do have the right template. I know that because there is an extra line break in the comment box that was not there before.

So something else is wrong. Here is the member_comment_bit.html code:
Quote
<tr>
  <td class="commentrow{row_bg_number}" nowrap="nowrap"> <strong>{comment_image}</strong></td>
  <td class="commentrow{row_bg_number}" nowrap="nowrap"><div align="right">Mark
      as read:
      <input type="checkbox" name="remove_id[{count}]" value="{comment_id}">
    </div></td>
</tr>
<tr>
  <td class="commentrow{row_bg_number}" valign="top" nowrap="nowrap"> <b>{comment_user_name}</b><br />
    {comment_user_gravatar}<br />
    {comment_user_info} {if comment_user_ip}<br /> <br /> <b>IP:</b> {comment_user_ip}{endif
    comment_user_ip} </td>
  <td width="100%" class="commentrow{row_bg_number}" valign="top"> <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td valign="top"><b>{comment_headline}</b></td>
        <td valign="top" align="right">{if admin_links}{admin_links}{endif admin_links}</td>
      </tr>
    </table>
    <hr size="1" />
    {comment_text} </td>
</tr>
<tr>
  <td class="commentrow{row_bg_number}" nowrap="nowrap"> <span class="smalltext">{comment_date}</span>
  </td>
  <td class="commentrow{row_bg_number}"> {comment_user_status_img} {comment_user_profile_button}
  </td>
</tr>
<tr>
  <td colspan="2" class="commentspacerrow"><img src="{template_url}/images/spacer.gif" width="1" height="1" alt="" /></td>
</tr>

Getting closer but still two problems - no default .gif instead of the gravatar and no gravatar in the comment box.

[UPDATE]
The more I am rereading the MOD for Show Received comments, it looks like if this MOD is installed, then some additional coding is needed in the member.php file to tell it to put the user_gravatar in the member_comment_bit.html file.

Thanks,

Brian

Also, I'll post on the Shoutbox MOD to ask where  I should put the or how to put the user_gravatar in the shoutbox, under the username.
Title: Re: [MOD] User Gravatars
Post by: surferboy on April 11, 2010, 03:29:29 AM
Hi -

Tried every possible permutation to make this MOD work. No luck.

One portion of the MOD works:

1. if the member has a gravatar account, their profile appears in the member profile. If the member does not have a gravatar account, the gravatar default icon appears there instead.

2. No gravatar or default icon appears at all in the comment boxl. As I said, I am using MOD Show Received Comments V.2. I tried adding the same code to the member_comment_bit.html but that did not work.

3. My default image that I would like to appear does not appear. Here is the code I tried to use in details.php:

Quote
$comment_user_gravatar = "<img src='http://www.gravatar.com/avatar.php?gravatar_id=$md5&amp;size=$default_size&amp;rating=$default_rating&amp;default=http://www.domain.com/galleryname/templates/default/images/our_image.gif' width='$default_size' height='$default_size' alt='' />";

4. I tried to use the same code in the member_profile.html so that our default avatar would appear. When I tried to paste this:

Quote
<img src='http://www.gravatar.com/avatar.php?gravatar_id=$md5&amp;size=$default_size&amp;rating=$default_rating&amp;default=http://www.domain.com/galleryname/templates/default/images/our_image.gif' width='$default_size' height='$default_size' alt='' />

in place of

Quote
<img src="http://www.gravatar.com/avatar.php?gravatar_id=<?=$md5?>&amp;size=<?=$default_size?>&amp;rating=<?=$default_rating?>" width="<?=$default_size?>" height="<?=$default_size?>" alt="" />

the entire gravatar disappears altogether. 

Kind of run out of ideas.

Anyone?

Thanks,

Brian
Title: Re: [MOD] User Gravatars
Post by: V@no on April 11, 2010, 04:17:17 AM
When you open the page where you expect to see avatar, look in it's source, perhaps it will give you some clues what is wrong.
Title: Re: [MOD] User Gravatars
Post by: surferboy on April 11, 2010, 09:38:43 AM
Hi -

Took a look at the page:
http://www.domain.com/ourgallery/member.php?action=readcomments

have uploaded both the comment_bit.html file and the member_comment_bit.html file and both files feature the added code:

<b>{comment_user_name}</b><br />
        {comment_user_gravatar}<br /> where this line is the one that needs to be added.

selected FF 3.6.3 View Page Source

if I upload the {comment_user_gravatar} to just the comment_bit.html but omit that code from the member_comment_bit.html,

then you don't see this line, all by itself: <br />

if I do upload that code to the member_comment_bit.html file, then yes, I see this <br /> on a line all by itself, right after the user name ...

which makes sense based on my previous post notes about the member_comment_bit.html having the  comment_user_gravatar code and there being an additional space opened in the comment box but nothing appeared, no image. If I remove that code so that the member_comment_bit.html reverted to the file before I started calling attention to it, there is no separator line even though the code is still present in coment_bit.html.

This confirms to me that because I have installed the MOD Show Received Comments V.2, topic 12695.0, the comment_bit.html is no longer called for in the php code and that the member.php and/or the details.php files are now working with member_comment_bit.html

so this brings the focus back to adjusting the code in the one of these two files, member.php or details.php to create an action to happen in the member_comment_bit.html file with the code {comment_user_gravatar} present.

I thought it might involved adding some code to the lines that feature

$comment_user_email = "";
perhaps adding a line similar like $comment_user_gravatar = "";

and then adding follow on code that is similar to each of the other comment lines, something like:

$comment_user_gravatar =
(isset($comment .... etc.

and also adding a similar code a little further down  where there are these comment lists:

"comment_user_id" => $comment_user_gravatar,

I tried adding this last bit but it didn't do anything. I have no idea what kind of code to write for the first section that has isset in it.

That's the best sleuthing I can do.

Thanks for reading this!

Brian
Title: Re: [MOD] User Gravatars
Post by: x23piracy on October 23, 2010, 12:50:56 PM
How can i show the gravatar of an user in their profile?
In member.php find:
Code: [Select]
     "user_email" => $user_email,

Insert below:
Code: [Select]
     "user_email_orig" => $user_row['user_email'],


In templates/<your template>/member_profile.html add:
Code: (template/HTML+PHP) [Select]
<?php
$default_size 
"50"// width/height of avatars
$default_rating "G"// An optional rating parameter may follow with a value of [ G | PG | R | X ] which determines the highest rating (inclusive) that will be returned. 
$md5 md5(strtolower("{user_email_orig}"));
?>

<img src="http://www.gravatar.com/avatar.php?gravatar_id=<?=$md5?>&amp;size=<?=$default_size?>&amp;rating=<?=$default_rating?>" width="<?=$default_size?>" height="<?=$default_size?>" alt="" />

Hi,

i like to display the gravatar on the member_editprofile.html

i've tryed this code in that file but the default gravatar is shown

Code: (template/HTML+PHP) [Select]
<?php
$default_size 
"50"// width/height of avatars
$default_rating "G"// An optional rating parameter may follow with a value of [ G | PG | R | X ] which determines the highest rating (inclusive) that will be returned. 
$md5 md5(strtolower("{user_email_orig}"));
?>

<img src="http://www.gravatar.com/avatar.php?gravatar_id=<?=$md5?>&amp;size=<?=$default_size?>&amp;rating=<?=$default_rating?>" width="<?=$default_size?>" height="<?=$default_size?>" alt="" />

that code allready exists in member.php

Code: [Select]
     "user_email_orig" => $user_row['user_email'],
but the gravatar is not shown any ideas? something missing?


Greetz X23