Index: includes/common.inc =================================================================== --- includes/common.inc (revision 0) +++ includes/common.inc (working copy) @@ -1931,10 +1931,35 @@ $last = $path; $path = preg_replace('`(^|/)(?!\.\./)([^/]+)/\.\./`', '$1', $path); } + + $path2 = substr($path, strlen(base_path())); + // Embed images that are less then 1K in size. + if ($image = image_get_info($path2)) { + if ($image['file_size'] < 1024) { + $path = data_uri_scheme($path2, $image['mime_type']); + } + } + return 'url('. $path .')'; } /** + * Generate data URI scheme to be used inside url() attribute. + * + * @param $file + * File path to generate data URI scheme from. + * @param $mime + * MIME type of file, e.g. image/png, image/gif. + * @return + * Data URI scheme to be used inside url() attribute. + */ +function data_uri_scheme($file, $mime) { + $contents = file_get_contents($file); + $base64 = base64_encode($contents); + return 'data:'. $mime .';base64,'. $base64; +} + +/** * Loads the stylesheet and resolves all @import commands. * * Loads a stylesheet and replaces @import commands with the contents of the