test inlining

This commit is contained in:
Bruno Rybársky 2024-02-04 10:34:57 +01:00
parent 1e82eb9ecd
commit bf3a523ab2

@ -14,12 +14,12 @@ function inlineLocalStylesFromHref($inputString) {
$cssContent = file_get_contents($_SERVER['DOCUMENT_ROOT'] . '/' . $href);
// Replace url() declarations in the CSS content with inline data
$cssContent = preg_replace_callback('/url\(["\']?(\/.*?)["\']?\)/i', function($urlMatch) {
$cssContent = preg_replace_callback('/url\(["\']?\/(.*?)(?:[?#].*?)?["\']?\)/i', function($urlMatch) {
// Extract the URL value
$url = $urlMatch[1];
// Get the content of the external file specified in the url()
$fileContent = file_get_contents($_SERVER['DOCUMENT_ROOT'] . $url);
$fileContent = file_get_contents($_SERVER['DOCUMENT_ROOT'] . '/' . $url);
// Base64 encode the content for inline use
$base64Content = base64_encode($fileContent);