forked from Adleraci/adlerka.top
test inlining
This commit is contained in:
parent
b2c69ee231
commit
b59414f836
@ -14,22 +14,18 @@ function inlineLocalStylesFromHref($inputString) {
|
|||||||
// Get the content of the local CSS file
|
// Get the content of the local CSS file
|
||||||
$cssContent = file_get_contents($_SERVER['DOCUMENT_ROOT'] . '/' . $href);
|
$cssContent = file_get_contents($_SERVER['DOCUMENT_ROOT'] . '/' . $href);
|
||||||
|
|
||||||
// Replace url() declarations in the CSS content with inline data
|
// Replace url() declarations in the CSS content with updated paths
|
||||||
$cssContent = preg_replace_callback('/url\(["\']?\/(.*?)(?:[?#].*?)?["\']?\)/i', function($urlMatch) {
|
$cssContent = preg_replace_callback('/url\(["\']?\/(.*?)(?:[?#].*?)?["\']?\)/i', function($urlMatch) {
|
||||||
// Extract the URL value
|
// Extract the URL value
|
||||||
$url = $urlMatch[1];
|
$url = $urlMatch[1];
|
||||||
echo "Hehe: $url";
|
|
||||||
|
|
||||||
// Get the content of the external file specified in the url()
|
// Modify the path as needed
|
||||||
$fileContent = file_get_contents($_SERVER['DOCUMENT_ROOT'] . '/' . $url);
|
$modifiedPath = '/new/path/' . $url;
|
||||||
|
|
||||||
// Base64 encode the content for inline use
|
// Create the updated url() declaration
|
||||||
$base64Content = base64_encode($fileContent);
|
$updatedUrlDeclaration = 'url("' . $modifiedPath . '")';
|
||||||
|
|
||||||
// Create the inline data URI
|
return $updatedUrlDeclaration;
|
||||||
$dataUri = 'url("data:application/octet-stream;base64,' . $base64Content . '")';
|
|
||||||
|
|
||||||
return $dataUri;
|
|
||||||
}, $cssContent);
|
}, $cssContent);
|
||||||
|
|
||||||
// Create an inline style tag with the modified CSS content
|
// Create an inline style tag with the modified CSS content
|
||||||
|
Loading…
Reference in New Issue
Block a user