MyBB Community Forums

Full Version: How do I get user avatar on the index?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Quote:<img src="{$mybb->user['avatar']}" alt="{$mybb->user['username']}" class="avatar" />

why wont this work?
Do you mean you want avatars to appear on the forums? Like for the last poster in that forum?
EDIT: Nevermind, you're right. I don't know why.
EDIT 2: Looks like at the end it has '/>'. I don't think it works in HTML5 anymore, and what I had used in mine was <img src="{$mybb->user['avatar']}" alt="{$mybb->user['username']}" class="avatar">.
Your code should work really.

This is how you do this in MyBB in a proper way. Firstly you need to generate avatar in PHP.
$useravatar = format_avatar(htmlspecialchars_uni($mybb->user['avatar']), $mybb->user['avatardimensions'], my_strtolower('100x100'));

Then this is a template code.
<img src="{$useravatar['image']}" alt="" {$useravatar['width_height']} />

Maybe someone has better solution without meddling with PHP code, but it doesn't look like it. In global.php there's even no "avatar" word.
(02-16-2015, 04:22 PM)mrnu Wrote: [ -> ]This is how you do this in MyBB in a proper way. First you need to generate avatar in PHP.

$useravatar = format_avatar(htmlspecialchars_uni($mybb->user['avatar']), $mybb->user['avatardimensions'], my_strtolower('100x100'));

Then this is a template code.

<img src="{$useravatar['image']}" alt="" {$useravatar['width_height']} />

Maybe someone has better solution without meddling with PHP code, but it doesn't look like it. In global.php there's even no "avatar" word.

This probably can work. I'll test it out for you.
EDIT: That isn't even working.
top one is working, was moving JS around and for some reason it stopped working
I recommend this
https://github.com/tommm/flpavatar

Fully working solution with cache