From 47de88918161d55a2a1ec86ff409778d8d4ba055 Mon Sep 17 00:00:00 2001 From: Brian Wolff Date: Sun, 19 Jul 2015 02:16:23 -0600 Subject: [PATCH] Show different message if image thumb in different format than img Users on commons feel that the other resolution links on the image page can be confusing to users if they are in a different format than the original image. Use a different message in that case to clarify the situation. See discussion at https://commons.wikimedia.org/?oldid=165672017 Change-Id: I76d7155e1c1e48a9824819135943d2385a0ee41a --- includes/page/ImagePage.php | 45 ++++++++++++++++++++++++++++++++----- languages/i18n/en.json | 1 + languages/i18n/qqq.json | 1 + 3 files changed, 41 insertions(+), 6 deletions(-) diff --git a/includes/page/ImagePage.php b/includes/page/ImagePage.php index e1cd76cb70..7957e6509d 100644 --- a/includes/page/ImagePage.php +++ b/includes/page/ImagePage.php @@ -382,13 +382,8 @@ class ImagePage extends Article { } $otherSizes = array_unique( $otherSizes ); - $msgsmall = ''; $sizeLinkBigImagePreview = $this->makeSizeLink( $params, $width, $height ); - if ( $sizeLinkBigImagePreview ) { - $msgsmall .= $this->getContext()->msg( 'show-big-image-preview' )-> - rawParams( $sizeLinkBigImagePreview )-> - parse(); - } + $msgsmall = $this->getThumbPrevText( $params, $sizeLinkBigImagePreview ); if ( count( $otherSizes ) ) { $msgsmall .= ' ' . Html::rawElement( @@ -632,6 +627,44 @@ EOT $out->setFileVersion( $this->displayImg ); } + /** + * Make the text under the image to say what size preview + * + * @param $params Array parameters for thumbnail + * @param $sizeLinkBigImagePreview HTML for the current size + * @return string HTML output + */ + private function getThumbPrevText( $params, $sizeLinkBigImagePreview ) { + if ( $sizeLinkBigImagePreview ) { + // Show a different message of preview is different format from original. + $previewTypeDiffers = false; + $origExt = $thumbExt = $this->displayImg->getExtension(); + if ( $this->displayImg->getHandler() ) { + $origMime = $this->displayImg->getMimeType(); + $typeParams = $params; + $this->displayImg->getHandler()->normaliseParams( $this->displayImg, $typeParams ); + list( $thumbExt, $thumbMime ) = $this->displayImg->getHandler()->getThumbType( + $origExt, $origMime, $typeParams ); + if ( $thumbMime !== $origMime ) { + $previewTypeDiffers = true; + } + } + if ( $previewTypeDiffers ) { + return $this->getContext()->msg( 'show-big-image-preview-differ' )-> + rawParams( $sizeLinkBigImagePreview )-> + params( strtoupper( $origExt ) )-> + params( strtoupper( $thumbExt ) )-> + parse(); + } else { + return $this->getContext()->msg( 'show-big-image-preview' )-> + rawParams( $sizeLinkBigImagePreview )-> + parse(); + } + } else { + return ''; + } + } + /** * Creates an thumbnail of specified size and returns an HTML link to it * @param array $params Scaler parameters diff --git a/languages/i18n/en.json b/languages/i18n/en.json index 8dbf0243d2..b284d09c78 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -2702,6 +2702,7 @@ "svg-long-error": "Invalid SVG file: $1", "show-big-image": "Original file", "show-big-image-preview": "Size of this preview: $1.", + "show-big-image-preview-differ": "Size of this $3 preview of this $2 file: $1.", "show-big-image-other": "Other {{PLURAL:$2|resolution|resolutions}}: $1.", "show-big-image-size": "$1 × $2 pixels", "file-info-gif-looped": "looped", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index bb248bd907..996685e503 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -2875,6 +2875,7 @@ "svg-long-error": "Displayed for invalid SVG file metadata. Parameters:\n* $1 - the error message\nSee also:\n* {{msg-mw|Thumbnail error}}", "show-big-image": "Displayed under the file on file description pages, when a reduced-size thumbnail of the original file is being displayed.\n{{Identical|Original file}}", "show-big-image-preview": "Message shown under the image description page thumbnail.\n\nCan be followed by {{msg-mw|Show-big-image-other}}.\n\nParameters:\n* $1 - a link which points to the thumbnail. Its text is {{msg-mw|Show-big-image-size}}", + "show-big-image-preview-differ": "Like {{msg-mw|show-big-image-preview}}, but used in the case where the thumbnail of the file is in a different format than the original image (e.g. For SVG or DjVu files).\n\n* $1 - a link which points to the thumbnail. Its text is {{msg-mw|Show-big-image-size}}\n* $2 Uppercase normalized extension of original file.\n* $3 Uppercased extension of thumbnail.", "show-big-image-other": "Message shown under the image description page thumbnail.\n\nPreceded by {{msg-mw|Show-big-image-preview}}, if the image is in high resolution.\n\nParameters:\n* $1 - list of resolutions (pipe-separated)\n* $2 - number of resolutions", "show-big-image-size": "Parameters:\n* $1 - the width of the image(s) in pixels\n* $2 - the height of the image(s) in pixels", "file-info-gif-looped": "Part of the information provided about a [[w:Gif|.gif file]] on its file description page. Looped means repeating in the context of an animated gif. It is a sequence of images, each displayed after the other, and the first one displayed after the last, in a never ending loop. For example of message in use see [[:File:Mouse10.gif]].\n{{Identical|Looped}}", -- 2.20.1