diff --git a/.gitignore b/.gitignore
index db1a90a5f..d94614fbf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -23,6 +23,7 @@ docker-compose.*.yml
# Ignore all files in the images folder other than listed below.
/images/*
+!/images/favicons
!/images/required.svg
!/images/user_icon.svg
/.gitattributes
diff --git a/favicon.ico b/favicon.ico
deleted file mode 100644
index 18f1b3167..000000000
Binary files a/favicon.ico and /dev/null differ
diff --git a/images/favicons/ec/favicon.ico b/images/favicons/ec/favicon.ico
new file mode 100644
index 000000000..5b1bb43a3
Binary files /dev/null and b/images/favicons/ec/favicon.ico differ
diff --git a/images/favicons/ec/favicon.png b/images/favicons/ec/favicon.png
new file mode 100644
index 000000000..997ab4e53
Binary files /dev/null and b/images/favicons/ec/favicon.png differ
diff --git a/images/favicons/ec/favicon.svg b/images/favicons/ec/favicon.svg
new file mode 100644
index 000000000..56f98f43d
--- /dev/null
+++ b/images/favicons/ec/favicon.svg
@@ -0,0 +1,78 @@
+
+
diff --git a/images/favicons/eu/favicon.ico b/images/favicons/eu/favicon.ico
new file mode 100644
index 000000000..c076906c0
Binary files /dev/null and b/images/favicons/eu/favicon.ico differ
diff --git a/images/favicons/eu/favicon.png b/images/favicons/eu/favicon.png
new file mode 100644
index 000000000..c277faba9
Binary files /dev/null and b/images/favicons/eu/favicon.png differ
diff --git a/images/favicons/eu/favicon.svg b/images/favicons/eu/favicon.svg
new file mode 100644
index 000000000..b72fb1d75
--- /dev/null
+++ b/images/favicons/eu/favicon.svg
@@ -0,0 +1,20 @@
+
+
diff --git a/oe_theme.theme b/oe_theme.theme
index c61b81997..6f0c1e8f7 100644
--- a/oe_theme.theme
+++ b/oe_theme.theme
@@ -2388,3 +2388,34 @@ function oe_theme_preprocess_select(&$variables) {
];
}
}
+
+/**
+ * Implements hook_page_attachments_alter().
+ */
+function oe_theme_page_attachments_alter(array &$attachments) {
+ // Use different favicon based on theme component library.
+ $active_theme = \Drupal::theme()->getActiveTheme();
+ if ($active_theme->getName() === 'oe_theme' || array_key_exists('oe_theme', $active_theme->getBaseThemeExtensions())) {
+ $component_library = theme_get_setting('component_library') ?? 'ec';
+ foreach ($attachments['#attached']['html_head_link'] as &$link) {
+ if ($link[0]['rel'] !== 'icon') {
+ continue;
+ }
+ $link[0]['href'] = base_path() . $active_theme->getPath() . "/images/favicons/$component_library/favicon.ico";
+ }
+ // Add the svg and png favicons.
+ $attachments['#attached']['html_head_link'][] = [
+ [
+ 'rel' => 'icon',
+ 'href' => base_path() . $active_theme->getPath() . "/images/favicons/$component_library/favicon.svg",
+ 'type' => 'image/svg+xml',
+ ],
+ ];
+ $attachments['#attached']['html_head_link'][] = [
+ [
+ 'rel' => 'apple-touch-icon',
+ 'href' => base_path() . $active_theme->getPath() . "/images/favicons/$component_library/favicon.png",
+ ],
+ ];
+ }
+}
diff --git a/tests/src/Functional/ConfigurationTest.php b/tests/src/Functional/ConfigurationTest.php
index 3a002b644..4ce184a6d 100755
--- a/tests/src/Functional/ConfigurationTest.php
+++ b/tests/src/Functional/ConfigurationTest.php
@@ -127,7 +127,9 @@ public function testChangeComponentLibrary(): void {
$this->assertLinkNotContainsHref('/oe_theme/dist/eu/styles/optional/ecl-rtl.css');
// Assert that the favicon provided by the theme is being used.
- $this->assertSession()->responseContains('/' . $active_theme . '/favicon.ico');
+ $this->assertSession()->responseContains("/$active_theme/images/favicons/eu/favicon.ico");
+ $this->assertSession()->responseContains("$active_theme/images/favicons/eu/favicon.png");
+ $this->assertSession()->responseContains("/$active_theme/images/favicons/eu/favicon.svg");
// Assert that we do not load the EC component library.
$this->assertLinkNotContainsHref('/oe_theme/dist/ec/styles/ecl-ec.css');
@@ -167,7 +169,9 @@ public function testChangeComponentLibrary(): void {
$this->assertLinkNotContainsHref('/oe_theme/dist/ec/styles/optional/ecl-rtl.css');
// Assert that the favicon provided by the theme is being used.
- $this->assertSession()->responseContains('/' . $active_theme . '/favicon.ico');
+ $this->assertSession()->responseContains("/$active_theme/images/favicons/ec/favicon.ico");
+ $this->assertSession()->responseContains("$active_theme/images/favicons/ec/favicon.png");
+ $this->assertSession()->responseContains("/$active_theme/images/favicons/ec/favicon.svg");
// Assert that we do not load the EU component library by default.
$this->assertLinkNotContainsHref('/oe_theme/dist/eu/styles/ecl-eu.css');