Fixed Font Awesome Icon is not displayed with <xf:fa>

Kirby

Well-known member
Affected version
2.3.0 Beta 2
Prerequisites
Development mode must be disabled

Steps to reproduce
Create an ad for position Container Content: Above with the following content
Code:
<xf:set var="$icon" value="fa-ambulance" />
<xf:fa icon="{$icon|raw}" />

Expected result
The ambulance icon is shown when viewing a public page just like it is in XF 2.2

Actual result
The HTML source code for the page contains
Code:
<i class="fa--xf far fa-ambulance ">
    <svg xmlns="http://www.w3.org/2000/svg" role="img" aria-hidden="true">
        <use href="<data-path>/local/icons/regular.svg?v=<ts>#ambulance"></use>
    </svg>
</i>
but no icon is shown.

Suggested Fix
Document the limitation that only icons that are part of the sprite can be used with <xf:fa> without explicitly setting option inline
or
Fallback to inline if the requested icon is not part of the sprite (Preferred as this retains XF 2.2 behaviour of always displaying the requested icon)
 
Last edited:
Still an issue in 2.3.0 Beta 3

In my understanding the sprite regular.svg is recreated whenever you use e.g. <xf:fa icon="fa-ambulance" /> in a template to include the missing icon.

However, if you try to use <xf:fa icon="{$var}" /> in conjunction with an icon class set by a variable the recreation not gonna work, thus the icon is not in the sprite and will not show up.

As a workaround you could use <xf:fa icon="fa-ambulance" /> in a new template which will never be used anywhere else only to trigger the recreation of the sprite. Now you can use it anywhere else dynamicly using a variable. I don't think that's intended.
 
We may add an auto-fallback for BC purposes, but ultimately you should either use the event listener to analyze your icons or add inline="true" if they really can't/shouldn't be analyzed.
 
We may add an auto-fallback for BC purposes, but ultimately you should either use the event listener to analyze your icons or add inline="true" if they really can't/shouldn't be analyzed.
the event listener...?

Did the analyzer ever get explained? https://xenforo.com/community/threa...e-in-xenforo-2-3.216767/#-icon-usage-analyzer this doesn't explain it, instead it says
We are aiming to go into a little more detail surrounding the icon usage analyzer in an upcoming developer-focused 'Have you seen...?'
but from what I can see, it does not exist in https://xenforo.com/community/threads/whats-new-for-developers-in-xenforo-2-3.217692/

Can you clarify, please?
 
Fallback to inline if the requested icon is not part of the sprite (Preferred as this retains XF 2.2 behaviour of always displaying the requested icon)
I still have documenting the analyzer a little better on my radar, but in the next version the inlining behavior is fully automatic.
 
Back
Top Bottom