* @file
*/
+use MediaWiki\MediaWikiServices;
use Wikimedia\Rdbms\ResultWrapper;
/**
return parent::getEmptyPageParserOutput( $options );
}
+ /**
+ * Returns language code to be used for dispaying the image, based on request context and
+ * languages available in the file.
+ *
+ * @param WebRequest $request
+ * @param File $file
+ * @return string|null
+ */
private function getLanguageForRendering( WebRequest $request, File $file ) {
- $handler = $this->displayImg->getHandler();
+ $handler = $file->getHandler();
if ( !$handler ) {
return null;
}
- $requestLanguage = $request->getVal( 'lang' );
- if ( !is_null( $requestLanguage ) ) {
- if ( $handler->validateParam( 'lang', $requestLanguage ) ) {
- return $requestLanguage;
- }
+ $config = MediaWikiServices::getInstance()->getMainConfig();
+ $requestLanguage = $request->getVal( 'lang', $config->get( 'LanguageCode' ) );
+ if ( $handler->validateParam( 'lang', $requestLanguage ) ) {
+ return $file->getMatchedLanguage( $requestLanguage );
}
- return $handler->getDefaultRenderLanguage( $this->displayImg );
+ return $handler->getDefaultRenderLanguage( $file );
}
protected function openShowImage() {
$dirmark = $lang->getDirMarkEntity();
$request = $this->getContext()->getRequest();
- $max = $this->getImageLimitsFromOption( $user, 'imagesize' );
- $maxWidth = $max[0];
- $maxHeight = $max[1];
+ list( $maxWidth, $maxHeight ) = $this->getImageLimitsFromOption( $user, 'imagesize' );
if ( $this->displayImg->exists() ) {
# image
# image
# "Download high res version" link below the image
# $msgsize = $this->getContext()->msg( 'file-info-size', $width_orig, $height_orig,
- # Linker::formatSize( $this->displayImg->getSize() ), $mime )->escaped();
+ # Language::formatSize( $this->displayImg->getSize() ), $mime )->escaped();
# We'll show a thumbnail of this image
if ( $width > $maxWidth || $height > $maxHeight || $this->displayImg->isVectorized() ) {
list( $width, $height ) = $this->getDisplayWidthHeight(
*
* @param User $user
* @param string $optionName Name of a option to check, typically imagesize or thumbsize
- * @return array
+ * @return int[]
* @since 1.21
*/
public function getImageLimitsFromOption( $user, $optionName ) {
}
/**
- * @param $lang string
- * @param $selected bool
+ * @param string $lang
+ * @param bool $selected
* @return string
*/
private function createXmlOptionStringForLanguage( $lang, $selected ) {