[Xfce4-commits] <www:master> Also inline the jpg.
Nick Schermer
noreply at xfce.org
Tue Apr 17 20:22:27 CEST 2012
Updating branch refs/heads/master
to aacebf674ad1394022de6e7c62a80e855992c785 (commit)
from bc343e44c0e37bac3e076d73c5eb1e950ae6e6ff (commit)
commit aacebf674ad1394022de6e7c62a80e855992c785
Author: Nick Schermer <nick at xfce.org>
Date: Tue Apr 17 18:12:55 2012 +0200
Also inline the jpg.
Saves a file transfer and 12% data.
style/css.php | 18 +++++++++---------
1 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/style/css.php b/style/css.php
index 3f49996..b552962 100644
--- a/style/css.php
+++ b/style/css.php
@@ -20,14 +20,14 @@ function write_header ($mtime)
function base64data ($matches)
{
$file = $matches[1] .'.'. $matches[2];
- $size = filesize ($file);
- if ($size > 0)
- {
- $imgbinary = fread (fopen ($file, "r"), $size);
- $base64 = base64_encode ($imgbinary);
-
- return "url('data:image/".$matches[2].";base64,$base64')";
- }
+
+ $buf = file_get_contents ($file);
+ if ($buf != false)
+ {
+ return 'url(\'data:image/'.
+ $matches[2].';base64,'.
+ base64_encode ($buf).'\')';
+ }
return $matches[0];
}
@@ -70,7 +70,7 @@ $buf = str_replace (array (': ', ' {', ', '), array (':', '{', ','), $buf); /* c
$buf = str_replace (array ("\r\n", "\r", "\n", "\t", ' '), '', $buf); /* strip lines and spaces */
/* embed images in css */
-$buf = preg_replace_callback ('!url\(\'([a-z/]*?).(png|gif)\'\)!', 'base64data', $buf);
+$buf = preg_replace_callback ('!url\(\'([a-z/-]*?).(png|gif|jpg)\'\)!', 'base64data', $buf);
/* output */
write_header ($mtime);
More information about the Xfce4-commits
mailing list