22 '#url\s*\(\s*(?(?=\'|").)(?!http\://|https\://|/|data\:)(.+?)(?:[\#\?].*?|[\'"])?\s*\)#';
35 $callback =
function (
$path) use ($offset) {
53 $patterns = self::extractRelativeUrls($cssContent);
64 $cssContent = str_replace(array_keys($replace), array_values($replace), $cssContent);
78 $parts = preg_split(
'/(@import\s.+?;\s*)/', $cssContent, -1, PREG_SPLIT_DELIM_CAPTURE);
81 foreach ($parts as $part) {
82 if (0 === strpos($part,
'@import', 0)) {
83 $imports[] = trim($part);
91 $result = implode(
"\n", $imports)
92 .
"\n/* The above import directives are aggregated from content. */\n" 104 private static function extractRelativeUrls($cssContent)
106 preg_match_all(self::REGEX_CSS_RELATIVE_URLS, $cssContent, $matches);
107 if (!empty($matches[0]) && !empty($matches[1])) {
108 return array_combine($matches[0], $matches[1]);
replaceRelativeUrls($cssContent, $inlineCallback)
call_user_func($callable, $param)
relocateRelativeUrls($cssContent, $relatedPath, $filePath)
static normalizePath($path)
aggregateImportDirectives($cssContent)
static offsetPath($relatedPath, $path)
const REGEX_CSS_RELATIVE_URLS