-
shazarak
Hi there!
need help with this situation:
i’m using Font Library, localized a couple of google fonts.
so i have a link like
https://www.website.it/wp-content/uploads/generatepress/fonts/fonts.csswith inside links like this
src: url(‘https://www.website.it/wp-content/uploads/generatepress/fonts/roboto/KFOmCnqEu92Fr1Mu4mxK.woff2’) format(‘woff2’);all is working correctly until I enable CDN ( using Bunny plugin or Perfmatters is the same)
so i can get a correct
https://cdn.website.it/wp-content/uploads/generatepress/fonts/fonts.cssbut, as Perfmatters support kindly explained me, all the links inside that font.css can’t be rewritten ( form any cdn plugin)
so now my website load quite all assets from CDN except 4 fonts coming from www.
and when i try to add a preload with perfmatters, it preload a cdn. font while then it get www. versionsMy question is: is there any where to fix this “problem” ? like there a filter for the absolute url in
uploads/generatepress/fonts/fonts.css ?
or a way to use relative url?i made a test and if i use link like this
src: url(‘/wp-content/uploads/generatepress/fonts/roboto/KFOmCnqEu92Fr1Mu4mxK.woff2’) format(‘woff2’);al seems to be rewritten correctly ( and downloaded only once)
thank you
and happy new year ๐
Fabio -
Hi there,
Happy new year ๐
i made a test and if i use link like this
src: url(โ/wp-content/uploads/generatepress/fonts/roboto/KFOmCnqEu92Fr1Mu4mxK.woff2โ) format(โwoff2โ);Yes, use relative URL is the fix.
-
shazarak
sorry, my fault and my bad english, try to explain better:
when i talk about “i made i test” it’s cause i copied code found in this file
https://www.website.it/wp-content/uploads/generatepress/fonts/fonts.css
and pated with relative url inside child style.css
i simply forced a file with a different url to test if it works.For what i know, and please let me kwon if i’m wrong, when you use Font Library system, GP will automatically download and put files into uploads/generatepress/fonts/ then create uploads/generatepress/fonts/fonts.css with the list of fonts selected and here is where it is written with absolute url
my need/question is how can i have urls inside uploads/generatepress/fonts/fonts.css not absolute so that any url rewriter can successfully rewrite urls with cdn subdomain
just to be clear, i’m searching a way to use Font Library system without the need to hardcode or overwrite manually code ( an example, if tomorrow i will add another font i would like not to “remember” to add more code or change it ecc )
thanks
-
It’s not possbile at this moment, unfortunately.
For now, manually copy/paste the CSS and modify the URLs is the workaround.
-
shazarak
ok, thank you.
so this font library is completely useless for those who want/need to use and CDN.
good to know, unfortunately.
just to be sure, the workaround is to create and install google fonts locally, then copy the font.css created, then disable fonts installed ( so that the file will be not created but the files will be fisically present), then paste css in another css with rewritten urls ?
cause if is simply copy paste, it will be alwasy a font.css as an unused asset to be loaded
If i can suggest, for the future, if possibile it would be great a “setting” on Font Library with a checkbox like “enable relative url for font file” so maybe someone who will need to rewrite some fonts urls will be capable of doing it without workaroung
thank you so much
Fabio -
just to be sure, the workaround is to create and install google fonts locally, then copy the font.css created, then disable fonts installed ( so that the file will be not created but the files will be fisically present), then paste css in another css with rewritten urls ?
Not that complicated, just copy the CSS from the
fonts.css
stylesheet, then paste it to your child theme CSS or customizer >additional CSS, the CSS should override thegeneratepress-fonts-css
.You don’t need to worry about the duplicated CSS code, the size of the
fonts.css
is very small, even with duplicated files, the impact on performance can be disregarded.And I agree that it should have an option to use relative URLs, I’ve created a feature request.
-
shazarak
i don’t like to serve an asset not used, but that’s what we have for now
will wait for a future options update ๐
thank you so much!
-
You are welcome and thanks for bringing this to our attention ๐
- You must be logged in to reply to this topic.