Merge "Add new rules when user is blocked for UTP"
[lhc/web/wiklou.git] / includes / resourceloader / ResourceLoaderImageModule.php
index 26d5e98..b711cbd 100644 (file)
@@ -39,6 +39,8 @@ class ResourceLoaderImageModule extends ResourceLoaderModule {
        protected $origin = self::ORIGIN_CORE_SITEWIDE;
 
        protected $images = [];
+       protected $defaultColor = null;
+       protected $useDataURI = true;
        protected $variants = [];
        protected $prefix = null;
        protected $selectorWithoutVariant = '.{prefix}-{name}';
@@ -50,7 +52,7 @@ class ResourceLoaderImageModule extends ResourceLoaderModule {
         *
         * @param array $options List of options; if not given or empty, an empty module will be
         *     constructed
-        * @param string $localBasePath Base path to prepend to all local paths in $options. Defaults
+        * @param string|null $localBasePath Base path to prepend to all local paths in $options. Defaults
         *     to $IP
         *
         * Below is a description for the $options array:
@@ -182,6 +184,10 @@ class ResourceLoaderImageModule extends ResourceLoaderModule {
                                        $this->{$member} = $option;
                                        break;
 
+                               case 'useDataURI':
+                                       $this->{$member} = (bool)$option;
+                                       break;
+                               case 'defaultColor':
                                case 'prefix':
                                case 'selectorWithoutVariant':
                                case 'selectorWithVariant':
@@ -264,7 +270,8 @@ class ResourceLoaderImageModule extends ResourceLoaderModule {
                                        $this->getName(),
                                        $fileDescriptor,
                                        $this->localBasePath,
-                                       $variantConfig
+                                       $variantConfig,
+                                       $this->defaultColor
                                );
                                $this->imageObjects[$skin][$image->getName()] = $image;
                        }
@@ -355,7 +362,7 @@ class ResourceLoaderImageModule extends ResourceLoaderModule {
                $script,
                $variant = null
        ) {
-               $imageDataUri = $image->getDataUri( $context, $variant, 'original' );
+               $imageDataUri = $this->useDataURI ? $image->getDataUri( $context, $variant, 'original' ) : false;
                $primaryUrl = $imageDataUri ?: $image->getUrl( $context, $script, $variant, 'original' );
                $declarations = $this->getCssDeclarations(
                        $primaryUrl,
@@ -440,7 +447,7 @@ class ResourceLoaderImageModule extends ResourceLoaderModule {
         * Extract a local base path from module definition information.
         *
         * @param array $options Module definition
-        * @param string $localBasePath Path to use if not provided in module definition. Defaults
+        * @param string|null $localBasePath Path to use if not provided in module definition. Defaults
         *     to $IP
         * @return string Local base path
         */