MyBB Community Forums

Full Version: Member profile avatar url?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,
At the moment my user profile uses this code to display the user avatar:
<div class="avatar">{$avatar}</div>
however the avatars move depending on the size of it. Now I have tried to use this:
<div class="avatar" style="width:100px; height:100px;">{$avatar}</div>
Although this does not work. Is there anyway I can display the user's avatar on their profile without having to use <div but instead use src (image path)? I am trying to make them all the same size.

Thanks in advance.
You could use something like this:

Quote:<img src="uploads/avatars/avatar_{$mybb->user['uid']}.png height="42px" width="42px">

I haven't tested it but I know from experience that the avatars get saved in the avatars sub-folder located in the uploads folder. Since my UID on the forum is 1, my avatars name is avatar_1.

Also, as you can see in the bold part which is the image extension. I put .png as an example. If you allow jpeg or gif images to be used for their avatars then there would be an issue because the html code I provided would not read other file extensions.
@Arbaz, that's not going to work with external avatars. Also, {$mybb->user['uid']} is UID from the person currently browsing page and running script, not from profile owner. So you would see your own avatar in every profile.

@kent55, you can use this instead:
<img src="{$memprofile['avatar']}" alt="" style="width:100px; height: 100px;" />
Or you can simply scale it in global.css:
.avatar img {
    width: 100px;
    height: 100px;
}
Thanks Smile