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) {
|
$cssContent = preg_replace_callback('/url\(["\']?(\/.*?|.*?)["\']?\)/i', function($urlMatch) use ($cssDir) {
|
||||||
$url = $urlMatch[1];
|
$url = $urlMatch[1];
|
||||||
$absolutePath = $cssDir . '/' . $url;
|
|
||||||
$relativePath = ltrim(substr($absolutePath, strlen($_SERVER['DOCUMENT_ROOT'])), '/');
|
// Check if the URL starts with any protocol or //
|
||||||
return 'url("' . $relativePath . '")';
|
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);
|
}, $cssContent);
|
||||||
|
|
||||||
// Minify the CSS content
|
// Minify the CSS content
|
||||||
|
Loading…
Reference in New Issue
Block a user