Not a bug Default avatar as text incorrectly displayed

Affected version
2.2.2

XFA

Well-known member
Using the following code in one of my add-ons:
Code:
<xf:avatar user="{{ phrase('xfa_rs_anonymous') }}" defaultname="{{ phrase('xfa_rs_anonymous') }}" size="s" notooltip="true" />

I discovered that the default avatar as text is incorrectly displayed.

The reason is that in that case the class applied the avatar in that case is the following:
Code:
avatar avatar--savatar--default avatar--default--dynamic
[/code

You see that the avatar--default is stucked to avatar-ss thus messing around (space missing).
 

Mike

XenForo developer
Staff member
I can't reproduce this and I don't think the code should directly allow it. Using the exact example you provided generates this HTML (obviously I don't have the phrases, but that shouldn't be relevant):

Code:
<span class="avatar avatar--s avatar--default avatar--default--dynamic" data-user-id="0" style="background-color: #521433; color: #d1478c" title="xfa_rs_anonymous">
            <span class="avatar-u0-s">X</span> 
        </span>

The relevant code actually explicitly adds a space before appending to the class attribute if needed:

Code:
if (empty($outerAttributes['class']))
{
   $outerAttributes['class'] = '';
}
else
{
   $outerAttributes['class'] .= ' ';
}
$outerAttributes['class'] .= 'avatar--default avatar--default--dynamic';

Can you still reproduce this?
 

XFA

Well-known member
Yes, for me the output is the following:
Code:
<span class="avatar avatar--savatar--default avatar--default--dynamic" data-user-id="0" style="background-color: lightgray; color: lightgray"><span class="avatar-u0-m">A</span></span>
 
Top