From 4ac9fa081a7c045f6a9f1cfc529d82423f485b2e Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 8 Dec 2013 09:55:49 +0100 Subject: Update to MediaWiki 1.22.0 --- .../resourceloader/ResourceLoaderLESSFunctions.php | 67 ++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 includes/resourceloader/ResourceLoaderLESSFunctions.php (limited to 'includes/resourceloader/ResourceLoaderLESSFunctions.php') diff --git a/includes/resourceloader/ResourceLoaderLESSFunctions.php b/includes/resourceloader/ResourceLoaderLESSFunctions.php new file mode 100644 index 00000000..c7570f64 --- /dev/null +++ b/includes/resourceloader/ResourceLoaderLESSFunctions.php @@ -0,0 +1,67 @@ +parser->sourceName, PATHINFO_DIRNAME ); + $url = $frame[2][0]; + $file = realpath( $base . '/' . $url ); + return $less->toBool( $file + && strpos( $url, '//' ) === false + && filesize( $file ) < CSSMin::EMBED_SIZE_LIMIT + && CSSMin::getMimeType( $file ) !== false ); + } + + /** + * Convert an image URI to a base64-encoded data URI. + * + * @par Example: + * @code + * .fancy-button { + * background-image: embed('../images/button-bg.png'); + * } + * @endcode + */ + public static function embed( $frame, $less ) { + $base = pathinfo( $less->parser->sourceName, PATHINFO_DIRNAME ); + $url = $frame[2][0]; + $file = realpath( $base . '/' . $url ); + + $data = CSSMin::encodeImageAsDataURI( $file ); + $less->addParsedFile( $file ); + return 'url(' . $data . ')'; + } +} -- cgit v1.2.3-54-g00ecf