XF 2.0 Need to grab user avatar

indepth

Member
I need to grab the user avatar for an external settings page. What is the correct way to do this?

It seems especially tricky since the default "avatar" is the letter in the users name and a random color.

If it helps I already have an instance of XF running on this external page load.
 
Do you need the avatar, completely parsed, or just the avatar url?
If you just need the url, you could do sth like
PHP:
\XF::app()->visitor()->getAvatarUrl("l"); // swap "l" out for the size
You might want to check getAvatarType() first, in case it's an gravatar, so you can fetch the avatar with getGravatarUrl() instead.
 
Just the URL. So that should work.

One question, what will it return if the user has not yet set an avatar and just has the letter w/ the random color?
 
Top Bottom