MyBB Community Forums

Full Version: Show avatar on index without plugin
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Can someone help me with this?
I want to show avatar of lastpost threads on index and without use a plugin

I already learn in index there is {$forums} and search in index.php about that string. It's string from functions_forumlist.php in inc folder, how to edit functions_forumlist.php to show avatar lastposter

Please help me
You can use this:

If the user does not have an avatar then this will display the default avatar for your forum.

<div class="avatar"><img src="{$mybb->user['avatar']}" onerror="this.src='/images/default_avatar.png';" /></div>
Sorry dude, i mean lastpost avatar in index, not the user avatar
not possible without plugin
As @Eldenroot says is very hard to do without a plugin or a charge on your server, i use some code core mods but the total of queryes and loads are more than using a plugin.

Actually i use a plugin for avatars and other for thread icons and prefixes and all goes very fine on latest versions.

My avatar plugin works very fine and have a var for images and one formated code to show styled avatars. All is up to date and works fine on 1.8.7 versions of mybb on many forums i see it. Anyway if you found an issue or get an idea or something more you can ask for it and i do what i can as fasta as i can.

Plugins actually are the best way to do and are hightly optimized, if any user tell not, well i only can say the programmer of flp plugin was one of the mybb core developers.

The code of my plugin is his code but changed only to work with 1.8 series and with some improvements, so i am pretty sure is a very optimized and working on version of avatars.

Test it by yourself last github repo i working on last details to upload here as stable and last revision. I am sure this version works so fine and have many options and entire customization.

Let me know if you use it and i try to help on guidance to get all advantages of this awesome work thank to Tom.
Haven't tried it out but report any errors, might of made a mistake somewhere, since it's pretty late here.

/* Our query. */
$lp_query = $db->simple_select('threads', 'lastposteruid', NULL);
$lp_fetch = $db->fetch_array($lp_query);

/* Get last poster's uid and the avatar.*/
$get_lp_uid = get_user($lp_fetch['lastposteruid']);
$lp_avatar = '<img src="'.$get_lp_uid['avatar'].'" width="40" height="40" style="border-radius: 100%;">';