You are here

function metatag_favicons_page_attachments_alter in Metatag 8

Implements hook_page_attachments_alter().

File

metatag_favicons/metatag_favicons.module, line 29
Custom hook implementations for Metatag Favicons.

Code

function metatag_favicons_page_attachments_alter(array &$attachments) {

  // Check html_head_link on attached tags in head.
  if (!isset($attachments['#attached']['html_head_link'])) {
    return;
  }

  // Remove the default shortcut icon if one was set by Metatag.
  foreach ($attachments['#attached']['html_head'] as $element) {
    if (isset($element[1]) && $element[1] == 'shortcut_icon') {
      foreach ($attachments['#attached']['html_head_link'] as $key => $value) {
        if (isset($value[0]['rel']) && $value[0]['rel'] == 'shortcut icon') {
          unset($attachments['#attached']['html_head_link'][$key]);
        }
      }
    }
  }
}