Handle favicon globally

This commit is contained in:
Kazhnuz 2025-07-15 16:56:15 +02:00
parent dc0b739e27
commit 6b6baab945
5 changed files with 27 additions and 4 deletions

View file

@ -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'));

View file

@ -17,4 +17,10 @@ class MediaHelper {
return MediaHelper::getImage($site->logo());
}
public static function getFavicon()
{
global $site;
return MediaHelper::getImage($site->favicon());
}
}

View file

@ -368,7 +368,11 @@ class Theme
public static function favicon($file = 'favicon.png', $typeIcon = 'image/png')
{
return '<link rel="icon" href="' . DOMAIN_THEME . $file . '" type="' . $typeIcon . '">' . PHP_EOL;
$favicon = MediaHelper::getFavicon();
if ($favicon == null) {
return "";
}
return '<link rel="icon" href="' . $favicon->permalink() . '" type="image/png">' . PHP_EOL;
}
public static function keywords($keywords)

View file

@ -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()

View file

@ -9,7 +9,7 @@
<?php echo Theme::metaTags('description'); ?>
<!-- Include Favicon -->
<?php echo Theme::favicon('img/favicon.png'); ?>
<?php echo Theme::favicon(); ?>
<!-- Include CSS Styles from this theme -->
<?php echo Theme::css('css/style.css'); ?>