diff --git a/phpBB/phpbb/template/twig/extension/icon.php b/phpBB/phpbb/template/twig/extension/icon.php
index f0748432a6..8edd33bbc7 100644
--- a/phpBB/phpbb/template/twig/extension/icon.php
+++ b/phpBB/phpbb/template/twig/extension/icon.php
@@ -83,7 +83,7 @@ class icon extends AbstractExtension
switch ($type)
{
case 'font':
- // Nothing to do here..
+ $classes = $this->insert_fa_class($classes);
break;
case 'png':
@@ -168,6 +168,39 @@ class icon extends AbstractExtension
}
}
+ /**
+ * Insert fa class into class string by checking if class string contains any fa classes
+ *
+ * @param string $class_string
+ * @return string Updated class string or original class string if fa class is already set or string is empty
+ */
+ protected function insert_fa_class(string $class_string): string
+ {
+ if (empty($class_string))
+ {
+ return $class_string;
+ }
+
+ // These also include pro class name we don't use, but handle them properly anyway
+ $fa_classes = ['fa-solid', 'fas', 'fa-regular', 'far', 'fal', 'fa-light', 'fab', 'fa-brands'];
+
+ // Split the class string into individual words
+ $icon_classes = explode(' ', $class_string);
+
+ // Check if the class string contains any of the fa classes, just return class string in that case
+ foreach ($icon_classes as $word)
+ {
+ if (in_array($word, $fa_classes))
+ {
+ return $class_string;
+ }
+ }
+
+ // If we reach this it means we didn't have any fa classes in the class string.
+ // Prepend class string with fas for fa-solid
+ return 'fas ' . $class_string;
+ }
+
/**
* Prepare an SVG for usage in the template icon.
*
diff --git a/tests/template/extension_test.php b/tests/template/extension_test.php
index 3050ed6c52..ea762f5b0f 100644
--- a/tests/template/extension_test.php
+++ b/tests/template/extension_test.php
@@ -313,7 +313,7 @@ class phpbb_template_extension_test extends phpbb_template_template_test_case
[
'ICON_PENCIL' => 'Pencil icon',
],
- '
+ '
Pencil icon'
],
/** Font: icons array */