blob: 9e269566f38d22b8b59e267fff538d3dc8a90c1a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
<?php /* -*- Mode: php; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
function preload($cssfile)
{
$css = file_get_contents($cssfile);
// TODO: Check for @import and do recursive parsing
?>
<div style="display: none;">
<?php
preg_match_all("|url\((.+)\)|U", $css, $urls);
// print_r($urls);
$path = dirname($cssfile);
$imgs = array_unique($urls[1]);
foreach($imgs as $_p) {
echo " <img alt=\"preload\" src=\"".$path . "/" . $_p."\"/>\n";
}
?>
</div>
<?php
}
?>
|