Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
bs_base
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
bs_base
Commits
f58f55d0
Commit
f58f55d0
authored
10 months ago
by
Ivica Puljic
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3435997
by pivica: Problem loading font preloads with query cache bust parameter
parent
026db6f0
Branches
2.x
Branches containing commit
No related tags found
1 merge request
!1
Issue #3435997 by pivica: Problem loading font preloads with query cache bust parameter
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bs_base.theme
+14
-3
14 additions, 3 deletions
bs_base.theme
themes/bs_bootstrap/sass/variables/_bs_bootstrap.scss
+3
-3
3 additions, 3 deletions
themes/bs_bootstrap/sass/variables/_bs_bootstrap.scss
with
17 additions
and
6 deletions
bs_base.theme
+
14
−
3
View file @
f58f55d0
...
...
@@ -139,9 +139,20 @@ function bs_base_preprocess_maintenance_page(&$variables) {
*/
function
bs_base_preload_fonts
(
array
$fonts
,
array
&
$attachments
)
{
foreach
(
$fonts
as
$font
)
{
// Font path can have ? query string for cache busting, which we need to
// remove when defining preload type and href.
if
(
str_contains
(
$font
,
'?'
))
{
$parts
=
explode
(
'?'
,
$font
,
2
);
$font
=
$parts
[
0
];
$query
=
$parts
[
1
];
}
else
{
$query
=
FALSE
;
}
// Support relative font path from root like '/libraries/.../....woff2' or
// remote font paths.
if
(
str
pos
(
$font
,
'/'
)
===
0
||
str
pos
(
$font
,
'http'
)
===
0
)
{
if
(
str
_starts_with
(
$font
,
'/'
)
||
str
_starts_with
(
$font
,
'http'
))
{
$uri
=
$font
;
}
// Support twig expansion syntax like @custom_theme/fonts/font1.woff.
...
...
@@ -149,7 +160,7 @@ function bs_base_preload_fonts(array $fonts, array &$attachments) {
$uri
=
\Drupal
::
service
(
'extension.list.theme'
)
->
getPath
(
$match
[
1
])
.
$match
[
2
];
}
// Support relative font path from the current active theme.
elseif
(
str
pos
(
$font
,
'/'
)
!==
0
)
{
elseif
(
!
str
_starts_with
(
$font
,
'/'
))
{
$active_theme
=
\Drupal
::
theme
()
->
getActiveTheme
();
$uri
=
$active_theme
->
getPath
()
.
'/'
.
$font
;
}
...
...
@@ -161,7 +172,7 @@ function bs_base_preload_fonts(array $fonts, array &$attachments) {
$attachments
[
'#attached'
][
'html_head_link'
][]
=
[[
'rel'
=>
'preload'
,
'as'
=>
'font'
,
'href'
=>
\Drupal
::
service
(
'file_url_generator'
)
->
generateString
(
$uri
),
'href'
=>
\Drupal
::
service
(
'file_url_generator'
)
->
generateString
(
$uri
)
.
(
$query
?
'?'
.
$query
:
''
)
,
'type'
=>
'font/'
.
pathinfo
(
$font
,
PATHINFO_EXTENSION
),
'crossorigin'
=>
'anonymous'
,
],
FALSE
];
...
...
This diff is collapsed.
Click to expand it.
themes/bs_bootstrap/sass/variables/_bs_bootstrap.scss
+
3
−
3
View file @
f58f55d0
...
...
@@ -88,11 +88,11 @@ $custom-file-text: () !default;
$bs-icon-use
:
true
!
default
;
// Use font hash when you need to cache bust previous font.
// If you are using font preloading for icons font do not forget to add the same
// cache in font preloading definition, for example if your hash is '1' then
// for preloading you need to add '?
1
' like 'fonts/icons.woff2?
1
'.
// cache in font preloading definition, for example if your hash is '1
23
' then
// for preloading you need to add '?
v=123
' like 'fonts/icons.woff2?
v=123
'.
$bs-icon-font-hash
:
false
!
default
;
// Do not change icons font name or font preloader will fail.
$bs-icon-font-src
:
url("../../fonts/icons.woff2
#{
if
(
$bs-icon-font-hash
,
'?'
+
$bs-icon-font-hash
,
''
)
}
")
format
(
"woff2"
)
!
default
;
$bs-icon-font-src
:
url("../../fonts/icons.woff2
#{
if
(
$bs-icon-font-hash
,
'?
v=
'
+
$bs-icon-font-hash
,
''
)
}
")
format
(
"woff2"
)
!
default
;
$bs-icon-font-family
:
'BS Icons'
!
default
;
$bs-icon-class
:
'fa'
!
default
;
// Additional icon shims.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment