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
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -295,18 +295,18 @@ function micro_site_page_attachments_alter(array &$attachments) {
      $favicon_changed = FALSE;
      $type = $file->getMimeType();
      $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'];
      foreach ($html_head_link as $key => $value) {
        if (isset($value[0]['rel'])) {
          switch ($value[0]['rel']) {
            case 'shortcut icon':
            case 'icon':
              $attachments['#attached']['html_head_link'][$key] = [
                [
                  'rel' => 'shortcut icon',
                  'rel' => 'icon',
                  'href' => UrlHelper::stripDangerousProtocols($favicon_url),
                  'type' => $type,
                ]
                ],
              ];
              $favicon_changed = TRUE;
              break;
@@ -316,7 +316,7 @@ function micro_site_page_attachments_alter(array &$attachments) {

      if (!$favicon_changed) {
        $attachments['#attached']['html_head_link'][][] = [
          'rel' => 'shortcut icon',
          'rel' => 'icon',
          'href' => UrlHelper::stripDangerousProtocols($favicon_url),
          'type' => $type,
        ];