let's say I'm trying to create an add-on that will modify every avatar, how can i do it?

Solution
No lol. My goal is just to create an overlay on avatars, Obviously I won't try to edit each avatar one by one.
Ah okay! Then i'd suggest checking out https://xenforo.com/community/resources/xb-user-profile-styles.9916/ as this already seems to do something similar to what your looking for.

If you want to do this yourself however.
From a quick test, modifying the src/XF/Template/Compiler/Tag/Avatar.php then running the command php cmd.php xf-dev:recompile-templates will work.

All I did was change the return from:
PHP:
return "{$compiler->templaterVariable}->func('avatar', array($user, $size, $canonical, $attributesCode))";
to:
PHP:
return '"<div class=\'avatar-wrapper\'>" . '
    ...
I'm a little confused on what your asking for exactly, but I don't think your going to achieve that using templates alone.

Now I only did a quick look into avatars so if anyone notices incorrect information please do let me know.

Avatars are stored in these files:
data/avatars/h/0/1.jpg
data/avatars/l/0/1.jpg
data/avatars/m/0/1.jpg
data/avatars/o/0/1.jpg
data/avatars/s/0/1.jpg

FolderMeaning
ssmall (thumbnail)
mmedium
llarge
hhigh-resolution
ooriginal upload

The file is called 1 this refers to the user id. These are the files you want to swap.

What might be better than manualy editing the avatar files is extending the src/XF/Template/Compiler/Tag/Avatar.php and modifying this to render in a new tag? I've never done this before though, and i'm unfamiliar with how the compiler works exactly. So i'd suggest looking into the source code before attempting this.
 
I'm a little confused on what your asking for exactly, but I don't think your going to achieve that using templates alone.

Now I only did a quick look into avatars so if anyone notices incorrect information please do let me know.

Avatars are stored in these files:
data/avatars/h/0/1.jpg
data/avatars/l/0/1.jpg
data/avatars/m/0/1.jpg
data/avatars/o/0/1.jpg
data/avatars/s/0/1.jpg

FolderMeaning
ssmall (thumbnail)
mmedium
llarge
hhigh-resolution
ooriginal upload

The file is called 1 this refers to the user id. These are the files you want to swap.

What might be better than manualy editing the avatar files is extending the src/XF/Template/Compiler/Tag/Avatar.php and modifying this to render in a new tag? I've never done this before though, and i'm unfamiliar with how the compiler works exactly. So i'd suggest looking into the source code before attempting this.
No lol. My goal is just to create an overlay on avatars, Obviously I won't try to edit each avatar one by one.
 
No lol. My goal is just to create an overlay on avatars, Obviously I won't try to edit each avatar one by one.
Ah okay! Then i'd suggest checking out https://xenforo.com/community/resources/xb-user-profile-styles.9916/ as this already seems to do something similar to what your looking for.

If you want to do this yourself however.
From a quick test, modifying the src/XF/Template/Compiler/Tag/Avatar.php then running the command php cmd.php xf-dev:recompile-templates will work.

All I did was change the return from:
PHP:
return "{$compiler->templaterVariable}->func('avatar', array($user, $size, $canonical, $attributesCode))";
to:
PHP:
return '"<div class=\'avatar-wrapper\'>" . '
    . $compiler->templaterVariable . '->func("avatar", array(' . $user . ', ' . $size . ', ' . $canonical . ', ' . $attributesCode . ')) . '
    . '"<span>Modified!</span></div>"';
and it changes the avatar
1762284210715.webp
 
Solution
Back
Top Bottom