test inlining
This commit is contained in:
parent
a904f050f6
commit
b2c69ee231
@ -1,12 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
function inlineLocalStylesFromHref($inputString) {
|
function inlineLocalStylesFromHref($inputString) {
|
||||||
// Define the regular expression pattern to match <link> tags with href attribute for CSS files
|
// Define the regular expression pattern to match <link> tags with href attribute for CSS files
|
||||||
$pattern = '/<link.*?(?:(?:rel=["\']stylesheet["\'].*?href=["\']\/(.*?)["\'])|(?:href=["\']\/(.*?)["\'].*?rel=["\']stylesheet["\'])).*?>/i';
|
$pattern = '/<link[^>]*?\srel=["\']?stylesheet["\'].*?\shref=["\']?\/(.*?)["\'][^>]*?>/i';
|
||||||
|
|
||||||
// Use preg_replace_callback to replace matched link tags with inline styles
|
// Use preg_replace_callback to replace matched link tags with inline styles
|
||||||
$outputString = preg_replace_callback($pattern, function($match) {
|
$outputString = preg_replace_callback($pattern, function($match) {
|
||||||
// Extract the href attribute value
|
// Extract the href attribute value
|
||||||
$href = isset($match[1]) ? $match[1] : $match[2];
|
$href = $match[1];
|
||||||
|
|
||||||
$fname = $_SERVER['DOCUMENT_ROOT'] . '/' . $href;
|
$fname = $_SERVER['DOCUMENT_ROOT'] . '/' . $href;
|
||||||
echo "from $fname";
|
echo "from $fname";
|
||||||
|
Loading…
Reference in New Issue
Block a user