e107inc / e107

e107 Bootstrap CMS (Content Management System) v2 with PHP, MySQL, HTML5, jQuery and Twitter Bootstrap. Issue Discussion Room: https://gitter.im/e107inc/e107
https://e107.org
GNU General Public License v3.0
320 stars 214 forks source link

Render favicon in admin area the same way as on frontend #5062

Closed Jimmi08 closed 11 months ago

Jimmi08 commented 1 year ago

Motivation

one rule for favicon rendering correct site favicon visible in admin asap after loading in prefs

Proposed Solution

renderFavicon() to admin header.php

Additional Context

It is easy to change. But the function renderFavicon() is part of header_default.php so it would be needed to copy to admin/header.php. And it means duplicate code for the same thing.

Thanks

// --------  Generate Apple Touch Icon ---------
echo renderFavicon();

function renderFavicon()
{
    // ---------- Favicon ---------
    if (file_exists(THEME . "favicon.ico"))
    {
        return "<link rel='icon' href='" . THEME_ABS . "favicon.ico' type='image/x-icon' />\n<link rel='shortcut icon' href='" . THEME_ABS . "favicon.ico' type='image/xicon' />\n";
    }
    elseif (file_exists(e_MEDIA_ICON . '16x16_favicon.png'))
    {
        $iconSizes = [16 => 'icon', 32 => 'icon', 48 => 'icon', 192 => 'icon', 167 => 'apple-touch-icon', 180 => 'apple-touch-icon'];
        $text = '';
        foreach ($iconSizes as $size => $rel)
        {
            $sizes = $size . 'x' . $size;
            $text .= "<link rel='$rel' type='image/png' sizes='$sizes' href='" . e_MEDIA_ICON_ABS . $sizes . "_favicon.png'>\n";
        }
        return $text;
    }
    elseif (file_exists(e_BASE . "favicon.ico"))
    {
        return "<link rel='icon' href='" . SITEURL . "favicon.ico' type='image/x-icon' />\n<link rel='shortcut icon' href='" . SITEURL . "favicon.ico' type='image/xicon' />\n";
    }
}
CaMer0n commented 11 months ago

@Jimmi08 This has been completed. Please comment here if you find any issues with the commit.