function google_fonts_api_page_attachments in @font-your-face 8.3
Implements hook_page_attachments().
File
- modules/
google_fonts_api/ google_fonts_api.module, line 36 - Google Fonts module file.
Code
function google_fonts_api_page_attachments(&$page) {
$enabled_fonts =& drupal_static('fontyourface_fonts', []);
$fonts = [];
foreach ($enabled_fonts as $font) {
if ($font->pid->value == 'google_fonts_api') {
$fonts[] = $font;
}
}
$url = google_fonts_api_generate_font_family_css($fonts);
if (!empty($url)) {
$page['#attached']['html_head'][] = [
[
'#type' => 'html_tag',
'#tag' => 'link',
'#attributes' => [
'rel' => 'stylesheet',
'href' => $url,
'media' => 'all',
],
],
'fontyourface-google-fonts-api',
];
}
}