Merge "Allow ResourceLoaderImage modules without data URIs"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Mon, 9 Jul 2018 14:24:36 +0000 (14:24 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Mon, 9 Jul 2018 14:24:36 +0000 (14:24 +0000)
1  2 
includes/resourceloader/ResourceLoaderImageModule.php

@@@ -40,6 -40,7 +40,7 @@@ class ResourceLoaderImageModule extend
  
        protected $images = [];
        protected $defaultColor = null;
+       protected $useDataURI = true;
        protected $variants = [];
        protected $prefix = null;
        protected $selectorWithoutVariant = '.{prefix}-{name}';
@@@ -51,7 -52,7 +52,7 @@@
         *
         * @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:
                                        $this->{$member} = $option;
                                        break;
  
+                               case 'useDataURI':
+                                       $this->{$member} = (bool)$option;
+                                       break;
                                case 'defaultColor':
                                case 'prefix':
                                case 'selectorWithoutVariant':
                $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,
         * 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
         */