X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fresourceloader%2FResourceLoaderImageModule.php;h=902fa91b7936c6ed456699eed9d00a26731b24f2;hb=9d37c792b2ee408b6a01b43a1a649e6074c11c34;hp=90b18ebd9cac469df5ac8d7fd7f29920c2b87825;hpb=ba7f053c556626339cd8bc56f61b0177115e4b5d;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/resourceloader/ResourceLoaderImageModule.php b/includes/resourceloader/ResourceLoaderImageModule.php index 90b18ebd9c..902fa91b79 100644 --- a/includes/resourceloader/ResourceLoaderImageModule.php +++ b/includes/resourceloader/ResourceLoaderImageModule.php @@ -130,7 +130,7 @@ class ResourceLoaderImageModule extends ResourceLoaderModule { $this->definition = null; if ( isset( $options['data'] ) ) { - $dataPath = $this->localBasePath . '/' . $options['data']; + $dataPath = $this->getLocalPath( $options['data'] ); $data = json_decode( file_get_contents( $dataPath ), true ); $options = array_merge( $data, $options ); } @@ -259,7 +259,7 @@ class ResourceLoaderImageModule extends ResourceLoaderModule { $this->images[$skin] = $this->images['default'] ?? []; } foreach ( $this->images[$skin] as $name => $options ) { - $fileDescriptor = is_string( $options ) ? $options : $options['file']; + $fileDescriptor = is_array( $options ) ? $options['file'] : $options; $allowedVariants = array_merge( ( is_array( $options ) && isset( $options['variants'] ) ) ? $options['variants'] : [], @@ -452,6 +452,18 @@ class ResourceLoaderImageModule extends ResourceLoaderModule { return array_map( [ __CLASS__, 'safeFileHash' ], $files ); } + /** + * @param string|ResourceLoaderFilePath $path + * @return string + */ + protected function getLocalPath( $path ) { + if ( $path instanceof ResourceLoaderFilePath ) { + return $path->getLocalPath(); + } + + return "{$this->localBasePath}/$path"; + } + /** * Extract a local base path from module definition information. *