protected function resolveCssRelatives($css, $base = '')
    {
        if (!($css = (string) $css)) {
            return $css; // Nothing to do.
        }
        $this->current_base = $base; // Make this available to callback handlers (possible empty string here).

        $import_without_url_regex = '/(?P<import>@(?:\-(?:'.$this->regex_vendor_css_prefixes.')\-)?import\s*)(?P<open_encap>["\'])(?P<url>.+?)(?P<close_encap>\\2)/ui';
        $any_url_regex            = '/(?P<url_>url\s*)(?P<open_bracket>\(\s*)(?P<open_encap>["\']?)(?P<url>.+?)(?P<close_encap>\\3)(?P<close_bracket>\s*\))/ui';

        $css = preg_replace_callback($import_without_url_regex, [$this, 'resolveCssRelativesImportCb'], $css);
        $css = preg_replace_callback($any_url_regex, [$this, 'resolveCssRelativesUrlCb'], $css);

        return $css;
    }
protected function resolveCssRelatives($css, $base = '')
    {
        if (!($css = (string) $css)) {
            return $css; // Nothing to do.
        }
        $this->current_base = $base; // Make this available to callback handlers (possible empty string here).

        $import_without_url_regex = '/(?P<import>@(?:\-(?:'.$this->regex_vendor_css_prefixes.')\-)?import\s*)(?P<open_encap>["\'])(?P<url>.+?)(?P<close_encap>\\2)/ui';
        $any_url_regex            = '/(?P<url_>url\s*)(?P<open_bracket>\(\s*)(?P<open_encap>["\']?)(?P<url>.+?)(?P<close_encap>\\3)(?P<close_bracket>\s*\))/ui';

        $css = preg_replace_callback($import_without_url_regex, [$this, 'resolveCssRelativesImportCb'], $css);
        $css = preg_replace_callback($any_url_regex, [$this, 'resolveCssRelativesUrlCb'], $css);

        return $css;
    }
protected function resolveCssRelatives ( $ css , $ base = '' ) { if ( ! ( $ css = ( string ) $ css ) ) { return $ css ; // Nothing to do. } $ this -> current_base = $ base ; // Make this available to callback handlers (possible empty string here). $ import_without_url_regex = '/(?P<import>@(?:\-(?:' . $ this -> regex_vendor_css_prefixes . ')\-)?import\s*)(?P<open_encap>["\'])(?P<url>.+?)(?P<close_encap>\\2)/ui' ; $ any_url_regex = '/(?P<url_>url\s*)(?P<open_bracket>\(\s*)(?P<open_encap>["\']?)(?P<url>.+?)(?P<close_encap>\\3)(?P<close_bracket>\s*\))/ui' ; $ css = preg_replace_callback ( $ import_without_url_regex , [ $ this , 'resolveCssRelativesImportCb' ] , $ css ) ; $ css = preg_replace_callback ( $ any_url_regex , [ $ this , 'resolveCssRelativesUrlCb' ] , $ css ) ; return $ css ; }
Resolve relative URLs in CSS code.

@since 140417 Initial release.

@param string $css  CSS code.
@param string $base Optional. Base URL to calculate from.
Defaults to the current HTTP location for the browser.

@return string CSS code after having all URLs resolved.
Resolve relative URLs in CSS code .