MyBB Community Forums

Full Version: {$mybb->user['avatar']}
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I noticed that the user's uploaded avatar when shown in the theme's template, it doesn't provide the full address to the avatar but with a relative path like "./uploads/adasdasdasd.jpg"

So, basically, all the page that uses the template outside the forums directory that try to retrieve the user's uploaded avatar will fail because of the relative path.

Anyway I can make it use full path instead of relative path?
Add $mybb->settings['bburl'] before it and remove everything before /uploads/ from $mybb->user['avatar'] [by using strpos() and substr() for example]
(2015-02-20, 11:24 PM)Destroy666 Wrote: [ -> ]Add $mybb->settings['bburl'] before it and remove everything before /uploads/ from $mybb->user['avatar'] [by using strpos() and substr() for example]

how about people who use external URL for avatar?
Just check if the URL is absolute/relative with a simple conditional first - for example if it starts with http:// or https:// (iIrc only these types of absolute links are allowed for avatar in MyBB).

EDIT: actually, checking $mybb->user['avatartype'] should be even easier. Its value is upload for uploaded ones.
Thanks.

Fixed it using template conditional and $mybb->user['avatartype'].