diff --git a/lib/inliner.php b/lib/inliner.php
index 8d5355a..f1ecbb8 100644
--- a/lib/inliner.php
+++ b/lib/inliner.php
@@ -12,14 +12,30 @@ function inlineLocalStylesFromHref($inputString) {
// Get the content of the local CSS file
$cssContent = file_get_contents($_SERVER['DOCUMENT_ROOT'] . '/' . $href);
- // Create an inline style tag with the CSS content
+ // Replace url() declarations in the CSS content with inline data
+ $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);
+
+ // Base64 encode the content for inline use
+ $base64Content = base64_encode($fileContent);
+
+ // Create the inline data URI
+ $dataUri = 'url("data:image/' . pathinfo($url, PATHINFO_EXTENSION) . ';base64,' . $base64Content . '")';
+
+ return $dataUri;
+ }, $cssContent);
+
+ // Create an inline style tag with the modified CSS content
return "";
}, $inputString);
return $outputString;
}
-
function inlineScriptFromSrc($inputString) {
// Define the regular expression pattern to match