From 1b6879c5910eda626c8f8c3978020e60d89e740c Mon Sep 17 00:00:00 2001 From: kpaxman <kpaxman@uwaterloo.ca> Date: Wed, 9 Jun 2021 15:44:45 -0400 Subject: [PATCH] ISTWCMS-4864: create manifest as array and JSON-encode rather than manually creating JSON --- uw_fdsu_theme_resp.theme | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/uw_fdsu_theme_resp.theme b/uw_fdsu_theme_resp.theme index 9ca3d434..c655ad30 100644 --- a/uw_fdsu_theme_resp.theme +++ b/uw_fdsu_theme_resp.theme @@ -212,14 +212,24 @@ function _uw_fdsu_theme_resp_add_favicons(array &$variables) { 'href' => $favicon_base_path . '/apple-touch-icon.png', ]; $variables['page']['#attached']['html_head_link'][] = [$favicon_apple]; + $manifest = [ + 'icons' => [ + [ + 'src' => $favicon_base_path . '/icon-192.png', + 'type' => 'image/png', + 'sizes' => '192x192', + ], + [ + 'src' => $favicon_base_path . '/icon-512.png', + 'type' => 'image/png', + 'sizes' => '512x512', + ] + ], + ]; + $manifest = json_encode($manifest); $favicon_manifest = [ 'rel' => 'manifest', - 'href' => 'data:application/manifest+json,{ - "icons": [ - { "src": "' . $favicon_base_path . '/icon-192.png", "type": "image/png", "sizes": "192x192" }, - { "src": "' . $favicon_base_path . '/icon-512.png", "type": "image/png", "sizes": "512x512" } - ] - }', + 'href' => 'data:application/manifest+json,' . $manifest, ]; $variables['page']['#attached']['html_head_link'][] = [$favicon_manifest]; } -- GitLab