X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fresourceloader%2FResourceLoaderImageModule.php;h=902fa91b7936c6ed456699eed9d00a26731b24f2;hb=ecc63fb7fe1134d064772fa71493575235b809ca;hp=db292ccddae8f23817d562b7c08b6b9ab3aa4111;hpb=8b22883a66bcc7d54be7acb9898defa545751f86;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/resourceloader/ResourceLoaderImageModule.php b/includes/resourceloader/ResourceLoaderImageModule.php index db292ccdda..902fa91b79 100644 --- a/includes/resourceloader/ResourceLoaderImageModule.php +++ b/includes/resourceloader/ResourceLoaderImageModule.php @@ -39,7 +39,7 @@ class ResourceLoaderImageModule extends ResourceLoaderModule { protected $origin = self::ORIGIN_CORE_SITEWIDE; - /** @var ResourceLoaderImage[]|null */ + /** @var ResourceLoaderImage[][]|null */ protected $imageObjects = null; /** @var array */ protected $images = []; @@ -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. *