Hey thanks for reaching out, I do remember this conversation with the FontAwesome team. I believe a fix is coming in a future release that will basically tell the JS to ignore the ‘fa-custom’ family class when rendering. But they stated it will only help ‘going forward’ and it sounds like that might only be for FontAwesome 7.
I did mention a possible workaround to them which it sounds like you’ve looked at a little. Currently if you have the icon set to return the “Icon Element” you would get something like this:
<i class="fa-kit fa-custom fa-drapes" aria-hidden="true"></i>
Changing the output to “Icon Object” would change what is returned to something like this:
stdClass Object
(
[element] => <i class="fa-kit fa-custom fa-drapes" aria-hidden="true"></i>
[class] => fa-kit fa-custom fa-drapes
[id] => drapes
[family] => kit
[style] => custom
[prefix] => fa-kit fa-custom
[hex] => \57346
[unicode] =>
[svg] => stdClass Object
(
[SVG data here I am going to ignore for this example]
)
)
Using the data in this object, you can build your own icon element to look however you need/want it to. You could do something like:
$icon_object = get_field( 'my_fa_icon' );
$icon_family = isset( $icon_object->family ) ? 'fa-' . $icon_object->family : '';
$icon_id = isset( $icon_object->id ) ? 'fa-' . $icon_object->id : '';
$icon = "<i class='" . $icon_family . " " . $icon_id . "' aria-hidden='true'></i>";
In this example, if you were to echo $icon you would get:
<i class="fa-kit fa-drapes" aria-hidden="true"></i>
-
This reply was modified 7 months ago by
Matt Keys.
-
This reply was modified 7 months ago by
Matt Keys.
It is worth mentioning why fa-custom is there to begin with. “Custom” is the styleName within the FontAwesome nomenclature for these custom uploaded icons. My plugin always outputs the Family (fa-kit), Style (fa-custom), and ID (fa-drapes) classes when generating an icon. I believe this is correct, but it seems in this case it was not considered in the FontAwesome JS renderer.
It is possible in a future update to this plugin I may break this standard if enough people are running into this issue and it isn’t something that FontAwesome can correct on their end. Currently you are the only one I’ve heard from on this (lucky you). If I change this to remove the fa-custom class I run the potential of causing more issues by removing a class that other users may be targeting in their CSS/JS. So I plan to let this play out for a little bit and see what kind of feedback I get from users, or what changes come down the line from the FontAwesome team.
Let me know if you have any issues with that workaround I gave you though and I’d be happy to help. Sorry you’ve been dealing with all of this!
-
This reply was modified 7 months ago by
Matt Keys.
-
This reply was modified 7 months ago by
Matt Keys.
Thanks so much for this info. I may wait and see if FontAwesome 7 resolves this issue. If it does not can you explain where I would be adding the code below to build your own icon element?
$icon_object = get_field( 'my_fa_icon' );$icon_family = isset( $icon_object->family ) ? 'fa-' . $icon_object->family : '';$icon_id = isset( $icon_object->id ) ? 'fa-' . $icon_object->id : '';$icon = "<i class='" . $icon_family . " " . $icon_id . "' aria-hidden='true'></i>";
Generally speaking, it would go very near wherever you were already using the_field( 'my_fa_icon' );
Like maybe you had some markup like this:
<div class="container">
<div class="my-icon-wrap">
<?php the_field( 'my_fa_icon' ); ?>
</div>
</div>
That would be converted to something like this:
<div class="container">
<div class="my-icon-wrap">
<?php
$icon_object = get_field( 'my_fa_icon' );
$icon_family = isset( $icon_object->family ) ? 'fa-' . $icon_object->family : '';
$icon_id = isset( $icon_object->id ) ? 'fa-' . $icon_object->id : '';
$icon = "<i class='" . $icon_family . " " . $icon_id . "' aria-hidden='true'></i>";
echo $icon;
?>
</div>
</div>
Exactly where you decide to put the code comes down to developer preference/style, but something like in my example above would certainly work.
Just wanted to chime in on this. I am running into the same issue. There was a naming convention put in place for our custom icons appending b- for basic icon and e- for extras. the b- won’t load, but all the others will, lol. I would just rename/reupload but it’s already live like that on way too many sites to ever go back and edit. Was hoping to implement this plugin to make things easier for customers of our sites.
@mattkeys I am working on testing this out with the release of FontAwesome 7. So far, no luck. In the setings > FontAwesome Version there isn’t an option for 7.x yet. Will that make a difference? The kit I am testing with is set to 7. Thanks!
I haven’t had an opportunity to test with FA7 yet but my assumption is that an update to my plugin will be required to support it.