From 6b6baab9455d543c4374b135516e9c5200bc83ba Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Tue, 15 Jul 2025 16:56:15 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Handle=20favicon=20globally?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bl-kernel/admin/views/settings.php | 9 +++++++++ bl-kernel/helpers/media.class.php | 6 ++++++ bl-kernel/helpers/theme.class.php | 6 +++++- bl-kernel/site.class.php | 8 ++++++-- bl-themes/defaultTheme/php/head.php | 2 +- 5 files changed, 27 insertions(+), 4 deletions(-) diff --git a/bl-kernel/admin/views/settings.php b/bl-kernel/admin/views/settings.php index a472e34c..601305a8 100644 --- a/bl-kernel/admin/views/settings.php +++ b/bl-kernel/admin/views/settings.php @@ -446,6 +446,15 @@ echo Bootstrap::formInputHidden(array( 'tip' => '' )); + echo Bootstrap::formSelectGallery(array( + 'name' => 'favicon', + 'label' => $L->g('Favicon'), + 'selected' => $site->favicon(), + 'class' => '', + 'placeholder' => '', + 'tip' => '' + )); + echo Bootstrap::cardEnd(); echo Bootstrap::cardBegin($L->g('Thumbnails')); diff --git a/bl-kernel/helpers/media.class.php b/bl-kernel/helpers/media.class.php index f2bca54f..976aa02f 100644 --- a/bl-kernel/helpers/media.class.php +++ b/bl-kernel/helpers/media.class.php @@ -17,4 +17,10 @@ class MediaHelper { return MediaHelper::getImage($site->logo()); } + public static function getFavicon() + { + global $site; + return MediaHelper::getImage($site->favicon()); + } + } \ No newline at end of file diff --git a/bl-kernel/helpers/theme.class.php b/bl-kernel/helpers/theme.class.php index 050a2f8a..bb842013 100644 --- a/bl-kernel/helpers/theme.class.php +++ b/bl-kernel/helpers/theme.class.php @@ -368,7 +368,11 @@ class Theme public static function favicon($file = 'favicon.png', $typeIcon = 'image/png') { - return '' . PHP_EOL; + $favicon = MediaHelper::getFavicon(); + if ($favicon == null) { + return ""; + } + return '' . PHP_EOL; } public static function keywords($keywords) diff --git a/bl-kernel/site.class.php b/bl-kernel/site.class.php index 712d7968..cf531db4 100644 --- a/bl-kernel/site.class.php +++ b/bl-kernel/site.class.php @@ -58,6 +58,7 @@ class Site extends dbJSON 'avatarHeight' => 400, // px 'avatarQuality' => 100, 'logo' => '', + 'favicon' => '', 'markdownParser' => true, 'customFields' => '{}', 'socials' => array() @@ -343,13 +344,16 @@ class Site extends dbJSON return $this->getField('titleFormatAuthor'); } - // Returns the absolute URL of the site logo - // If you set $absolute=false returns only the filename public function logo() { return $this->getField('logo'); } + public function favicon() + { + return $this->getField('favicon'); + } + // Returns the full domain and base url // For example, https://www.domain.com/koblog public function url() diff --git a/bl-themes/defaultTheme/php/head.php b/bl-themes/defaultTheme/php/head.php index 022197be..e32a64b0 100644 --- a/bl-themes/defaultTheme/php/head.php +++ b/bl-themes/defaultTheme/php/head.php @@ -9,7 +9,7 @@ - +