This is a pretty simple process. With the new ExpressionEngine PB2 release, you can easily allow your members to have a member avatar. I’ll explain how I did it here.
Create a new custom member profile field. You can do this by going to Admin -> Custom Profile Fields (Under Members and Groups).
Call the field whatever you would like.
I called it member_avatar – Avatar URL (50×50 image), text input, 127 characters.
Basically, this is the URL to the image that your member will be using.
Save that field.
Now, you need to set up the comments (or wherever you show comments) template to use the member avatar. Here’s the code I used to put it in:
That code will check to see if the member_avatar variable is blank, and if it’s not, display it, restricting to 50×50 pixels in size. I also put in that it should be right aligned in that comment (float:right).
You should put that code anywhere in the exp:comments tag. I put mine before the {comment} tag itself.
This is not restricted to just comments. You can also use these for authors of entries. The principle is the same, except you will be putting it into the exp:weblog:entries tag. Actually, this functionality (for entries) has been in from the beginning, but I thought to add that in here.
If you have any questions or want to see more of the code, let me know!
- Excited
- Fascinated
- Amused
- Bored
- Sad
- Angry
Thanks for posting this.
How difficult would it be to have the avatar show up in the member’s profile page?
strange, i posted a comment and it’s saying (1) under comments, but my comment isn’t there. Will this one show up?
Um, ok, that’s 2 comments not showing up. Are you using the comment moderation feature or something?
it was because i was using my old tbcomments which apparently doesn’t work anymore hehe. I’ll have to investigate that.
For the member’s profile page, i would have to say it would pretty easy, you just add the same code into the members template.
Hmmm, I got this working GREAT on my site, people are commenting and I’m having a great time my first day on EE (MT-reject here ;) )
BUT – on the public member profile template it’s NOT working – but it’s working on a friend of mine’s site no problem *sigh*
Here’s the code:
{if member_avatar != “"}< img src="{member_avatar}" border="0" width="50" height="50" alt="” class="floatpicleft" />{/if} {name} is in the {member_group} group, has written {total_entries} entries and has commented {total_comments} times.
Without the space in < img src of course ;)
Well, while that code outputs FINE in my comments, when it’s in the member profile it shows the image box, and checking the source of the image shows me this:
<a href="http://www.mysite.com/index.php/member/3/<p>http://www.theirsite.com/images/avatar.gif” target=”_blank”>http://www.mysite.com/index.php/member/3/<p>http://www.theirsite.com/images/avatar.gif
Which leaves me CLUELESS :D
Any idea what it could be? something related to my general settings??
ok – looks like i totally bonked that comment – did you get it or should i repost? ;)
I saw it just fine. no problem. I’ll edit it later so everyone else can see it. : )
The only thing I can think of in your case is the output method. Usually when you get the opening/closing paragraphs, you have the XHTML setting set as formatting for that field. You might want to check your format settings for that custom variable and make sure it’s set to none. That would be your best bet.
yup, it’s set to none for the field. And I’m still clueless LOL
Scratch that. I lied.
:D
Thanks for your help, and thanks for the great idea :)
Thank you Yoshi for posting this, it was a breeze to implement, even for a novice like me!
I would like to feature a random member’s info with their avatar on my index page. Right now I can get the info to appear, but not the avatar (well, the avatar shows up when it’s within the exp:weblog:entries tag). I’m just wondering if this is a lost cause. Can I only use this script to make the avatar appear when it’s within the exp:weblog:entries or comments tags?
Thanks again!
Hey, this script is awesome and I got it working perfectly on my blog, but theres one little problem. It doesn’t work on any of my other blogs on the same site besides the default one. I even used the same template and nothing. Am I doing something wrong? Does it have to be changed somehow if it’s in a different blog?
Works fine for a single comment, but when there is more than one no avatar is displayed.
Yoshi – I’m trying to use this on my site and when someone puts the link in on their own, they get an error message.
MySQL ERROR:
Error Number: 1054
Description: Unknown column ‘HTTP_REFERER’ in ‘field list’
Query: UPDATE exp_member_data SET m_field_id_1 =
‘http:/imagepath’, HTTP_REFERER =
‘ http://www.leftofwest.org/index.php/member/profile/P1/’” rel=”nofollow”>;http://www.leftofwest.org/index.php/member/profile/P1/’ WHERE member_id =
‘XX’
However, if I put the link in for them, it works. Is it possible I have something funky in a config file somewhere?
this is test guys
I can give any reference to mine of avatars how the size an avatar in kilobytes is supervised?
I’m afraid you’ll have to trust your members on what size the kilobytes be set at. You can specify in your member preferences perhaps to make sure that avatars are not to exceed a typical size, but I don’t think you can specify the size if it’s on an outside URL.
I used the method described above for adding hot linked avatars to our forums. Unfortunately the avatars do not show up and only the code itself is displayed. I am placing the code into the “Thread Rows” section of the Discussion Forum module’s template.
Any ideas on how to fix that, so that the avatars show up?
The last I checked, custom member fields weren’t displayed in the forum templates. Actually there are a lot of things that don’t show up in in the forum templates. :/