X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fresourceloader%2FResourceLoaderImage.php;h=d38a17500814c8d89b9a6f11ce1a6a147fab0597;hb=048089ae3a052deaac1003996247ce86e5a60bfc;hp=072ae7944b177af4842c3a29a8135e1c0639a774;hpb=2c12b1fd2afc14a03c16f05c844320985d911ca0;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/resourceloader/ResourceLoaderImage.php b/includes/resourceloader/ResourceLoaderImage.php index 072ae7944b..d38a175008 100644 --- a/includes/resourceloader/ResourceLoaderImage.php +++ b/includes/resourceloader/ResourceLoaderImage.php @@ -130,13 +130,27 @@ class ResourceLoaderImage { $desc = $this->descriptor; if ( is_string( $desc ) ) { return $this->basePath . '/' . $desc; - } elseif ( isset( $desc['lang'][$context->getLanguage()] ) ) { - return $this->basePath . '/' . $desc['lang'][$context->getLanguage()]; - } elseif ( isset( $desc[$context->getDirection()] ) ) { + } + if ( isset( $desc['lang'] ) ) { + $contextLang = $context->getLanguage(); + if ( isset( $desc['lang'][$contextLang] ) ) { + return $this->basePath . '/' . $desc['lang'][$contextLang]; + } + $fallbacks = Language::getFallbacksFor( $contextLang ); + foreach ( $fallbacks as $lang ) { + // Images will fallback to 'default' instead of 'en', except for 'en-*' variants + if ( + ( $lang !== 'en' || substr( $contextLang, 0, 3 ) === 'en-' ) && + isset( $desc['lang'][$lang] ) + ) { + return $this->basePath . '/' . $desc['lang'][$lang]; + } + } + } + if ( isset( $desc[$context->getDirection()] ) ) { return $this->basePath . '/' . $desc[$context->getDirection()]; - } else { - return $this->basePath . '/' . $desc['default']; } + return $this->basePath . '/' . $desc['default']; } /**