• Resolved keyvan

    (@keyvan)


    If I have a CSS file with something like the following:

    .header { background:url(/wp-content/uploads/2019/11/bg.jpg) }

    When it gets combined, it will turn into something like the following:

    .header { background:url(https://example.org/wp-content/themes/mytheme//wp-content/uploads/2019/11/bg.jpg)) }

    I had a look at the code and it looks like the function get_style_content_with_replacements in Combinator.php doesn’t treat path-absolute-URL strings correctly. I think these should be treated the same way as you treat absolute URL strings (ie. left alone).

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Hristo Pandjarov

    (@hristo-sg)

    SiteGround Representative

    We’re doing this because once we combine the file it is saved in a different location than the original ones. So if we keep the relative paths, they would be incorrect.

    Thread Starter keyvan

    (@keyvan)

    Fair enough, but then you’re not resolving it correctly.

    A path-absolute-URL can’t simply be appended to the base URL, as you’re doing in the code.

    So if you see a URL that looks like /wp-content/uploads/2019/11/bg.jpg and the base URL you’ve built is https://example.org/wp-content/themes/mytheme/, the final URL should be https://example.org/wp-content/uploads/2019/11/bg.jpg

    but instead I’m getting https://example.org/wp-content/themes/mytheme//wp-content/uploads/2019/11/bg.jpg and this path doesn’t exist, so the image doesn’t load.

    • This reply was modified 5 years ago by keyvan.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Combine CSS bug with path-absolute URLs?’ is closed to new replies.