Skip to content
Snippets Groups Projects
Commit 2859d8dd authored by Kevin Paxman's avatar Kevin Paxman Committed by Kevin Paxman
Browse files

Add favicons (not sure if manifest format will work)

parent c7473831
No related branches found
No related tags found
2 merge requests!32Tag 1.0.1,!29ISTWCMS-4864: add favicons
...@@ -26,13 +26,50 @@ require_once dirname(__FILE__) . '/includes/views.inc'; ...@@ -26,13 +26,50 @@ require_once dirname(__FILE__) . '/includes/views.inc';
/** /**
* Implements hook_preprocess_HOOK(). * Implements hook_preprocess_HOOK().
* *
* Setting the faculty class colour. * Setting the faculty class colour and favicon information.
*/ */
function uw_fdsu_theme_resp_preprocess_html(&$variables) { function uw_fdsu_theme_resp_preprocess_html(&$variables) {
// Adding the faculty colour class to the body. // Adding the faculty colour class to the body.
$variables['attributes']['class'][] = theme_get_setting('wcms_colour_scheme', 'uw_fdsu_theme_resp') ? theme_get_setting('wcms_colour_scheme', 'uw_fdsu_theme_resp') : 'org-default'; $variables['attributes']['class'][] = theme_get_setting('wcms_colour_scheme', 'uw_fdsu_theme_resp') ? theme_get_setting('wcms_colour_scheme', 'uw_fdsu_theme_resp') : 'org-default';
$variables['uw_admin_page'] = \Drupal::service('uw_cfg_common.uw_analytics')->administrationPage(); $variables['uw_admin_page'] = \Drupal::service('uw_cfg_common.uw_analytics')->administrationPage();
// Remove Drupal's favicon.
foreach ($variables['page']['#attached']['html_head_link'] as $id => $html_head_link) {
if (isset($html_head_link[0]['rel']) && $html_head_link[0]['rel'] == 'shortcut icon') {
unset($variables['page']['#attached']['html_head_link'][$id]);
break;
}
}
// Specify new favicon locations.
// Based on https://evilmartians.com/chronicles/how-to-favicon-in-2021-six-files-that-fit-most-needs.
$favicon = [
'rel' => 'icon',
'href' => base_path() . drupal_get_path('theme','uw_fdsu_theme_resp') . '/favicon.ico',
];
$variables['page']['#attached']['html_head_link'][] = [$favicon];
$favicon_svg = [
'rel' => 'icon',
'href' => base_path() . drupal_get_path('theme','uw_fdsu_theme_resp') . '/icon.svg',
'type' => 'image/svg+xml',
];
$variables['page']['#attached']['html_head_link'][] = [$favicon_svg];
$favicon_apple = [
'rel' => 'apple-touch-icon',
'href' => base_path() . drupal_get_path('theme','uw_fdsu_theme_resp') . '/apple-touch-icon.png',
];
$variables['page']['#attached']['html_head_link'][] = [$favicon_apple];
$favicon_manifest = [
'rel' => 'manifest',
'href' => 'data:application/manifest+json,{
"icons": [
{ "src": "' . base_path() . drupal_get_path('theme','uw_fdsu_theme_resp') . '/icon-192.png", "type": "image/png", "sizes": "192x192" },
{ "src": "' . base_path() . drupal_get_path('theme','uw_fdsu_theme_resp') . '/icon-512.png", "type": "image/png", "sizes": "512x512" }
]
}',
];
$variables['page']['#attached']['html_head_link'][] = [$favicon_manifest];
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment