forked from Adleraci/adlerka.top
test inlining
This commit is contained in:
parent
c5aa686997
commit
409d214538
@ -11,9 +11,16 @@ function inlineLocalStylesFromHref($inputString) {
|
||||
|
||||
$cssContent = preg_replace_callback('/url\(["\']?(\/.*?|.*?)["\']?\)/i', function($urlMatch) use ($cssDir) {
|
||||
$url = $urlMatch[1];
|
||||
$absolutePath = $cssDir . '/' . $url;
|
||||
$relativePath = ltrim(substr($absolutePath, strlen($_SERVER['DOCUMENT_ROOT'])), '/');
|
||||
return 'url("' . $relativePath . '")';
|
||||
|
||||
// Check if the URL starts with any protocol or //
|
||||
if (!preg_match('/^([a-zA-Z]+:)?\/\//', $url)) {
|
||||
$absolutePath = $cssDir . '/' . $url;
|
||||
$relativePath = ltrim(substr($absolutePath, strlen($_SERVER['DOCUMENT_ROOT'])), '/');
|
||||
return 'url("' . $relativePath . '")';
|
||||
} else {
|
||||
// If the URL starts with a protocol or //, leave it unchanged
|
||||
return 'url("' . $url . '")';
|
||||
}
|
||||
}, $cssContent);
|
||||
|
||||
// Minify the CSS content
|
||||
|
Loading…
Reference in New Issue
Block a user