1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-13 16:44:36 +02:00

fix(icon-plugin): show fallback icon if icon name is not valid or doesn't exists. #400

This commit is contained in:
Awilum
2020-03-08 11:25:58 +03:00
parent 41ea2814ae
commit e003995c54

View File

@@ -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;
}