From 09638b0c9ba2816c79bb7ecaf5e294931b85b7bf Mon Sep 17 00:00:00 2001 From: Jason Whitmore Date: Fri, 18 Apr 2025 16:27:28 -0700 Subject: [PATCH] MediaInterface.kt: fix MediaWiki API call to retrieve thumbnail URLs properly Before this change, the API calls to MediaWiki would request thumbnails with atleast a specific width, rather than height. These thumbnails would often be extremely low resolution on very wide images, such as panoramas. This change instead requests thumbnails with atleast a specific height. Panorama thumbnails are now at a higher resolution than before. Additionally, the height parameter is now represented as an integer which can be changed more easily. --- .../fr/free/nrw/commons/media/MediaInterface.kt | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/fr/free/nrw/commons/media/MediaInterface.kt b/app/src/main/java/fr/free/nrw/commons/media/MediaInterface.kt index ef0ef1f9c..7becde8c1 100644 --- a/app/src/main/java/fr/free/nrw/commons/media/MediaInterface.kt +++ b/app/src/main/java/fr/free/nrw/commons/media/MediaInterface.kt @@ -186,13 +186,25 @@ interface MediaInterface { ): Single companion object { + /** + * Retrieved thumbnail height will be about this tall, but must be at least this height. + * A larger number means higher thumbnail resolution but more network usage. + */ + const val THUMB_HEIGHT_PX = 220 + const val MEDIA_PARAMS = - "&prop=imageinfo|coordinates&iiprop=url|extmetadata|user&&iiurlwidth=640&iiextmetadatafilter=DateTime|Categories|GPSLatitude|GPSLongitude|ImageDescription|DateTimeOriginal|Artist|LicenseShortName|LicenseUrl" + "&prop=imageinfo|coordinates&iiprop=url|extmetadata|user&&iiurlheight=" + + THUMB_HEIGHT_PX + + "&iiextmetadatafilter=DateTime|Categories|GPSLatitude|GPSLongitude|" + + "ImageDescription|DateTimeOriginal|Artist|LicenseShortName|LicenseUrl" /** * fetches category detail(title, hidden) for each category along with File information */ const val MEDIA_PARAMS_WITH_CATEGORY_DETAILS = - "&clprop=hidden&prop=categories|imageinfo&iiprop=url|extmetadata|user&&iiurlwidth=640&iiextmetadatafilter=DateTime|GPSLatitude|GPSLongitude|ImageDescription|DateTimeOriginal|Artist|LicenseShortName|LicenseUrl" + "&clprop=hidden&prop=categories|imageinfo&iiprop=url|extmetadata|user&&iiurlheight=" + + THUMB_HEIGHT_PX + + "&iiextmetadatafilter=DateTime|GPSLatitude|GPSLongitude|ImageDescription|" + + "DateTimeOriginal|Artist|LicenseShortName|LicenseUrl" } }