Changing Avatar Urls

pldcanfly

Member
Hi,

for a heavily bridged forum I need to replace the avatars with ones I fetch from our login-service.

We want to keep the standart Xen-Foro-Avatars (custom, gravatar) and just replace the default one with the corresponding avatar for the user.

My main problem is that I can't manage to find the function to extend/override that handles <xen:avatar>.

Could you please give me a hint at this?

Greetings
Thomas

PS: XenForo: 1.2.1
 
You'll probably need to override it as it is a static function...

But check out: XenForo/Template/Helper/Core.php

There's a function pertaining to custom avatars, gravatar avatars and I believe default avatars.
 
I feel silly now... I wondered why my listener on load_class didn't work and your mentioning of "static" triggered my brain to work properly.

Thanks. You were right.

( XenForo/Template/Helper/Core.php => _getDefaultAvatarUrl() )
 
I feel silly now... I wondered why my listener on load_class didn't work and your mentioning of "static" triggered my brain to work properly.

Thanks. You were right.

( XenForo/Template/Helper/Core.php => _getDefaultAvatarUrl() )
For Template_Helper_Core You must using init_dependencies for extending ;)
 
You still cannot extend existing functions in that class.

You can override helper functions in init_dependencies because you can modify the XenForo_Template_Helper_Core::$helpers array to replace the existing functions (or add new ones).

Furthermore, you can't override or extend a function such as _getDefaultAvatarUrl because that is just a static function called by the helper function.
 
That means the best solution will to override it in $helpers and use the original source code to maintain the standart-behaviour. At least it is a lot cleaner then hacking it in the core itself.
 
I went with hacking it (_getDefaultAvatar() -> library/xenforo/templates/helper/core.php) since time was an issue.
 
Yes, but I will start working today or tomorrow on making this properly since the "hack" was just to cut time :). I will post how I did it when i'm finished.
 
Sometimes we find the answer to our questions in an oblique way! I created my own "default avatar" images, but saved them in jpg, as for some reason the pngs were too heavy. I just didn't know how to change the link to them, but found in the core.php file the png extension, which I changed to jpg, and bingo!

Thanks Chris!
 
Top Bottom