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.
This commit is contained in:
Jason Whitmore 2025-04-18 16:27:28 -07:00
parent 0ed9dac5d6
commit 09638b0c9b

View file

@ -186,13 +186,25 @@ interface MediaInterface {
): Single<MwQueryResponse> ): Single<MwQueryResponse>
companion object { 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 = 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 * fetches category detail(title, hidden) for each category along with File information
*/ */
const val MEDIA_PARAMS_WITH_CATEGORY_DETAILS = 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"
} }
} }