nortmas
9/27/2017 - 2:40 PM

Attachments alter

// to add library to all pages

/**
 * Implements hook_page_attachments_alter().
 */
function hook_page_attachments_alter(&$attachments) {
  $attachments['#attached']['library'][] = 'module_name/library_name';
  
  // Remove the stock Drupal favicon if it is present.
  if (isset($attachments['#attached']['html_head_link'])) {
    foreach ($attachments['#attached']['html_head_link'] as $key => $config) {
      if (isset($config[0]['rel']) && $config[0]['rel'] === 'shortcut icon') {
        unset($attachments['#attached']['html_head_link'][$key]);
      }
    }
  }
  
}