From e003995c547844637cd91d022641d556eccddbc5 Mon Sep 17 00:00:00 2001 From: Awilum Date: Sun, 8 Mar 2020 11:25:58 +0300 Subject: [PATCH] fix(icon-plugin): show fallback icon if icon name is not valid or doesn't exists. #400 --- site/plugins/icon/app/Controllers/IconController.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/site/plugins/icon/app/Controllers/IconController.php b/site/plugins/icon/app/Controllers/IconController.php index d6935e30..cc342bbe 100644 --- a/site/plugins/icon/app/Controllers/IconController.php +++ b/site/plugins/icon/app/Controllers/IconController.php @@ -25,11 +25,20 @@ class IconController extends Controller $icon_category = 'brands'; } elseif ($icon_parts[0] == 'far') { $icon_category = 'regular'; + } else { + $icon_category = 'regular'; } $icon_name = str_replace("fa-", "", $icon_parts[1]); - $icon = Filesystem::read(PATH['plugins'] . '/icon/assets/dist/fontawesome/svgs/' . $icon_category . '/' . $icon_name . '.svg'); + $icon_file_path = PATH['plugins'] . '/icon/assets/dist/fontawesome/svgs/' . $icon_category . '/' . $icon_name . '.svg'; + $icon_fallback_file_path = PATH['plugins'] . '/icon/assets/dist/fontawesome/svgs/regular/file-alt.svg'; + + if (Filesystem::has($icon_file_path)) { + $icon = Filesystem::read($icon_file_path); + } else { + $icon = Filesystem::read($icon_fallback_file_path); + } return $icon; }