• Resolved kolaps

    (@kolapsnet)


    Have WP with WPML (domain setup, 3 domains: DE with domain xxxx.de, EN with domain yyyyy.com and SI (Slovenian) with domain zzzzzz.si..
    I got problem with minify css – orginal file have relative path
    background-image: url('assets/img/svg/caret-bold.svg');
    When I look cached file on SI domain wpo-minify-header-style.min.css got
    background-image:url(https://xxxx.de/wp-content/themes/mymobilehomes/assets/img/svg/caret-bold.svg)
    full path from main domain and not of Slovenian domain.. And now cached files are loaded from xxxx.de domain, but assets are loaded from zzzzz.si domain..

    Is it possible to disable full path and use local path for css minify?

    • This topic was modified 8 months ago by kolaps.
    • This topic was modified 8 months ago by kolaps.
Viewing 4 replies - 1 through 4 (of 4 total)
  • wpmansour

    (@wpmansour)

    Currently, the feature to disable the full domain path in CSS minification isn’t available in WP-Optimize. However, I’ll pass your feedback to the development team for future consideration.

    In the meantime, you can achieve this using some custom code for an immediate solution.

    Thread Starter kolaps

    (@kolapsnet)

    some example? or maybe some filter? any documentation about filters?

    wpmansour

    (@wpmansour)

    Sure, you can use a custom filter to achieve this. Here’s an example of how you can use the wpo_minify_css_string filter to convert the URLs in your minified CSS files to relative paths:

    add_filter('wpo_minify_css_string', 'wpo_custom_minify_css_paths');
    function wpo_custom_minify_css_paths($css_content) {
    $css_content = preg_replace_callback(
    '/url\((\'|")?(https?:\/\/[^\/]+)?\/([^\'"\)]+)(\'|")?\)/i',
    function ($matches) {
    return 'url(' . $matches[1] . '/' . $matches[3] . $matches[4] . ')';
    },
    $css_content
    );
    return $css_content;
    }

    Just add this code to your theme’s functions.php file, and it should handle the issue by converting the URLs in your minified CSS files to relative paths.

    Thread Starter kolaps

    (@kolapsnet)

    Thanks a lot, working!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Minify css problem with full domain path – WPML domain setup’ is closed to new replies.