mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Url.php: Allow findOsImage() to also use the first two words of $feature (#11049)
* Url.php: Allow findOsImage() to also use the first two words of $feature * LibreNMS is not always using the bunded redhat.svg. * Modern RHEL has /etc/os-release and distro ends up using it. * The lsb release is correct, i.e. 'Red Hat Enterprise Linux Server 7.6' * Previously, findOsImage() only considered the first word of $feature as a possibility for the icon. * This patch allows using the first two words (with the space removed) * i.e. 'Red Hat' becomes 'redhat' and findOsImage uses the bundled redhat.svg * Url.php: use null as an argument rather than '' * Url.php: only replaceFirst if there is a space in $feature
This commit is contained in:
committed by
Kevin Krumm
parent
6ffde9ce2d
commit
a2c227ba4c
@ -382,9 +382,18 @@ class Url
|
||||
|
||||
if ($os) {
|
||||
if ($os == "linux") {
|
||||
// first, prefer the first word of $feature
|
||||
$distro = Str::before(strtolower(trim($feature)), ' ');
|
||||
$possibilities[] = "$distro.svg";
|
||||
$possibilities[] = "$distro.png";
|
||||
|
||||
// second, prefer the first two words of $feature (i.e. 'Red Hat' becomes 'redhat')
|
||||
if (strpos($feature, ' ') !== false) {
|
||||
$distro = Str::replaceFirst(' ', null, strtolower(trim($feature)));
|
||||
$distro = Str::before($distro, ' ');
|
||||
$possibilities[] = "$distro.svg";
|
||||
$possibilities[] = "$distro.png";
|
||||
}
|
||||
}
|
||||
$os_icon = Config::getOsSetting($os, 'icon', $os);
|
||||
$possibilities[] = "$os_icon.svg";
|
||||
|
Reference in New Issue
Block a user