Skip to content
Snippets Groups Projects
Commit 4ec3195a authored by Tim Rabbetts's avatar Tim Rabbetts Committed by fabrice.scoyer
Browse files

Issue #3270947 by zarexogre, flocondetoile: Favicon for microsites doesnt work for D9

parent f9af9a44
No related branches found
No related tags found
No related merge requests found
...@@ -295,18 +295,18 @@ function micro_site_page_attachments_alter(array &$attachments) { ...@@ -295,18 +295,18 @@ function micro_site_page_attachments_alter(array &$attachments) {
$favicon_changed = FALSE; $favicon_changed = FALSE;
$type = $file->getMimeType(); $type = $file->getMimeType();
$favicon_uri = $file->getFileUri(); $favicon_uri = $file->getFileUri();
$favicon_url = file_url_transform_relative(file_create_url($favicon_uri)); $favicon_url = \Drupal::service('file_url_generator')->generateString($favicon_uri);
$html_head_link = $attachments['#attached']['html_head_link']; $html_head_link = $attachments['#attached']['html_head_link'];
foreach ($html_head_link as $key => $value) { foreach ($html_head_link as $key => $value) {
if (isset($value[0]['rel'])){ if (isset($value[0]['rel'])) {
switch ($value[0]['rel']) { switch ($value[0]['rel']) {
case 'shortcut icon': case 'icon':
$attachments['#attached']['html_head_link'][$key] = [ $attachments['#attached']['html_head_link'][$key] = [
[ [
'rel' => 'shortcut icon', 'rel' => 'icon',
'href' => UrlHelper::stripDangerousProtocols($favicon_url), 'href' => UrlHelper::stripDangerousProtocols($favicon_url),
'type' => $type, 'type' => $type,
] ],
]; ];
$favicon_changed = TRUE; $favicon_changed = TRUE;
break; break;
...@@ -316,7 +316,7 @@ function micro_site_page_attachments_alter(array &$attachments) { ...@@ -316,7 +316,7 @@ function micro_site_page_attachments_alter(array &$attachments) {
if (!$favicon_changed) { if (!$favicon_changed) {
$attachments['#attached']['html_head_link'][][] = [ $attachments['#attached']['html_head_link'][][] = [
'rel' => 'shortcut icon', 'rel' => 'icon',
'href' => UrlHelper::stripDangerousProtocols($favicon_url), 'href' => UrlHelper::stripDangerousProtocols($favicon_url),
'type' => $type, 'type' => $type,
]; ];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment