From b5f16cc10953650c7efda10faba3696d1f54a4ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Ryb=C3=A1rsky?= Date: Sun, 4 Feb 2024 11:11:03 +0100 Subject: [PATCH] test inlining --- lib/inliner.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/inliner.php b/lib/inliner.php index ae102e6..5c078f8 100644 --- a/lib/inliner.php +++ b/lib/inliner.php @@ -10,12 +10,12 @@ function inlineLocalStylesFromHref($inputString) { $cssContent = file_get_contents($cssFilePath); $cssDir = dirname($cssFilePath); -// $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 . '")'; -// }, $cssContent); + $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 . '")'; + }, $cssContent); // Minify the CSS content //$cssContent = minifyCss($cssContent);