Grav: Rewriting of relative URLs breaks when using Google Fonts and the CSS pipeline

Created on 4 Apr 2016  路  3Comments  路  Source: getgrav/grav

The issues occurs when Google Fonts are being used in the asset manager as follows:
{% do assets.addCss('https://fonts.googleapis.com/css?family=Roboto', 101) %}

For example, adding this line to the base.twig.html partial of the default _antimatter_ theme results in Font Awesome not being loaded properly due to 404's: the URLs of the fonts are not rewritten.

Example:

{% block stylesheets %}
    {% do assets.addCss('https://fonts.googleapis.com/css?family=Roboto', 104) %}
    {% do assets.addCss('theme://css/pure-0.5.0/grids-min.css', 103) %}
    {% do assets.addCss('theme://css-compiled/nucleus.css',102) %}
    {% do assets.addCss('theme://css-compiled/template.css',101) %}
    {% do assets.addCss('theme://css/custom.css',100) %}
    {% do assets.addCss('theme://css/font-awesome.min.css',100) %}
    {% do assets.addCss('theme://css/slidebars.min.css') %}

    {% if browser.getBrowser == 'msie' and browser.getVersion == 10 %}
        {% do assets.addCss('theme://css/nucleus-ie10.css') %}
    {% endif %}
    {% if browser.getBrowser == 'msie' and browser.getVersion >= 8 and browser.getVersion <= 9 %}
        {% do assets.addCss('theme://css/nucleus-ie9.css') %}
        {% do assets.addJs('theme://js/html5shiv-printshiv.min.js') %}
    {% endif %}
{% endblock %}
bug recreated

All 3 comments

Problem recreated. Related forum discussion: https://getgrav.org/forum#!/theme-development:css-pipeline-breaks-image-p

I recreated by having in system.yaml

assets:
  css_pipeline: true
  css_rewrite: true

Adding {% do assets.addCss('https://fonts.googleapis.com/css?family=Roboto', 101) %}
and loading fontawesome, the fontawesome CSS relative paths are not rewritten for some reason, so the relative URLs break.

If I remove the Google Font and clear the cache, CSS rewrite works fine.

Hello,
I was about to post the same issue (cssRewrite not triggered when pipelining CSS if assets contain remote link.).
I found out that inside the gatherLinks method in Assets.php the $local variable is set to false after the first remote link and remains false for all other local links, so cssRewrite is not called and all relative links in css remain "as is" and become incorrect in resulting pipelined css.

Already had it fixed, was just testing :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jimblue picture jimblue  路  4Comments

flaviocopes picture flaviocopes  路  5Comments

carstenwm picture carstenwm  路  3Comments

josefstr picture josefstr  路  4Comments

i5o picture i5o  路  3Comments