minify icon indicating copy to clipboard operation
minify copied to clipboard

CSS url with relative paths being rewritten incorrectly

Open kevinnivek opened this issue 3 years ago • 3 comments

I notice when CSS is minified , url references with relative paths (with double quotes) are being rewritten incorrectly :

before :

url("fonts/212c8ce9-e668-4bbf-ab50-783ebeaa2d8a.woff2")

after :

url(../wp-content/themes/theme/fonts/212c8ce9-e668-4bbf-ab50-783ebeaa2d8a.woff2)

This breaks the loading of most of my fonts and things of that nature.

kevinnivek avatar May 20 '21 10:05 kevinnivek

No fix for that?

Before:

url(../webfonts/fa-brands-400.woff2)

After:

url(../../../../public_html/modules/painel/fonts/font-awesome/webfonts/fa-brands-400.woff2)

scorninpc avatar May 12 '22 01:05 scorninpc

AFAIK Minify doesn't update the paths inside the CSS. It could be some other feature or plugin. But could you please provide a test case? Should look like this:

$tests[] = array(
            '<<ACTUAL UNMINIFIED CSS>>',
            '<<EXPECTED MINIFIED CSS>>',
        );

Please check tests/css/CSSTest.php for examples.

short-pixel-optimizer avatar May 15 '22 06:05 short-pixel-optimizer

I had the same problem. I commented out the two lines 339-340 in src/CSS.php and the symptoms stopped occurring.

            $converter = $this->getPathConverter($source, $path ? : $source);
            $css = $this->move($converter, $css);

matsumoto-magicword avatar Sep 30 '22 13:09 matsumoto-magicword