diff --git a/uw_fdsu_theme_resp.theme b/uw_fdsu_theme_resp.theme index 1fe6908bf3b8025f361e8463ca492f1a1018e1fd..e92f15a89777bcfb1e771d244d14f2a2dc308685 100644 --- a/uw_fdsu_theme_resp.theme +++ b/uw_fdsu_theme_resp.theme @@ -26,13 +26,50 @@ require_once dirname(__FILE__) . '/includes/views.inc'; /** * 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) { // 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['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]; } /**