MyBB Community Forums

Full Version: How to style {$avatar} in member_profile template?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
How to style {$avatar} in member_profile template?
Adding a border?
Unfortunately you've to edit ./member.php file since the <img src=""> tag has been used in the core file, rather to have a separate template.

Open ./member.php file and find;
$avatar = "<img src=\"{$memprofile['avatar']}\" alt=\"\" $avatar_width_height />";
and Change it into;
$avatar = "<img src=\"{$memprofile['avatar']}\" alt=\"\" $avatar_width_height class=\"member_avatar\"/>";

Then you've to define its CSS in global.css like this;
.member_avatar{
border: 3px double #000;
/* DEFINE YOUR CSS HERE */
}

You can't do simply by editing the template because if a user hasn't an avatar then the avatar area will have a vacant space with the CSS styling.
@Op
I came across this when I wanted to style the avatar on profiles, too. The best way is to create a new image, basically. Something like:

<img src="{$memprofile['avatar']}" class="profileAvatar" alt="" />

Replace the {$avatar} with that and style the class.
But if a user hasn't uploaded his avatar then the area will show a broken image Jordan.
Ah, good point. The code I used was on iOSNut, and there is a default image on there. There's a jQuery code I have laying around somewhere that displays a URL in place of any empty avatar URL. I'll try and dig it up for the OP.
If the img src would be good, you could try to use the Template Conditionals plugin, better than editing core file for sure. Anyways the $memprofile['avatar'] is not working for me.
Code would be like this:
<td class="{$alt_bg}" align="center"><if $user['avatar'] then>
<img src="{$memprofile['avatar']}" class="profileAvatar"/>
</if></td>
Great advice guys, thank you.
(2012-04-21, 11:04 PM)Destroy666 Wrote: [ -> ]If the img src would be good, you could try to use the Template Conditionals plugin, better than editing core file for sure. Anyways the $memprofile['avatar'] is not working for me.
Code would be like this:
<td class="{$alt_bg}" align="center"><if $user['avatar'] then>
<img src="{$memprofile['avatar']}" class="profileAvatar"/>
</if></td>

Actually, it should be this:

<if $memprofile['avatar'] then>
    <img src="{$memprofile['avatar']}" class="profileAvatar" />
</if>
thanks Smile awesome
Pages: 1 2