Page MenuHomePhabricator

Media list endpoint returning unexpected and out of order item responses
Open, LowPublic

Description

It seems the media list endpoint (https://en.wikipedia.org/api/rest_v1/page/media-list/) is returning out of order and unexpected results for some articles. This leads to unexpected behavior in the iOS client, where tapping a lead image or swiping through the list of media items in the gallery provides an incongruent experience with what's presented in the article itself.

Here are a couple of cases with example articles we've noticed.

1. Out of order

Below are snippets from mobile HTML and media list endpoint responses for "Amazon rainforest". Since Amazon_biome_outline_map is specified as the leadImage, there's an expectation that it'd be the first item in the media list, but because it's out of order (as the second item instead of the first), there's unexpected behavior in the client.

<meta property="mw:leadImage" content="https://upload.wikimedia.org/wikipedia/commons/thumb/5/54/Amazon_biome_outline_map.svg/371px-Amazon_biome_outline_map.svg.png" data-file-width="371" data-file-height="279">
"items": [
{
  "title": "File:Amazon_Manaus_forest.jpg",
  "section_id": 0,
  "type": "image",
  "showInGallery": true,
  "srcset": [
	{
	  "src": "//upload.wikimedia.org/wikipedia/commons/thumb/4/4b/Amazon_Manaus_forest.jpg/640px-Amazon_Manaus_forest.jpg",
	  "scale": "1x"
	},
	{
	  "src": "//upload.wikimedia.org/wikipedia/commons/thumb/4/4b/Amazon_Manaus_forest.jpg/960px-Amazon_Manaus_forest.jpg",
	  "scale": "1.5x"
	}
  ]
},
{
  "title": "File:Amazon_biome_outline_map.svg",
  "section_id": 0,
  "type": "image",
  "showInGallery": true,
  "srcset": [
	{
	  "src": "//upload.wikimedia.org/wikipedia/commons/thumb/5/54/Amazon_biome_outline_map.svg/320px-Amazon_biome_outline_map.svg.png",
	  "scale": "1x"
	}
  ]
},
]
2. Missing Media

Here's a case where an image visible in the article is missing from the media list. The first image in the "Meteorological history" section is present in the article, but appears to be missing in the media list.

Expected Endpoint Behavior
  1. The media list does not exclude images visible in article (case 2)
  2. The order of items in the media list matches the order of items in the article (case 1)
  3. Mobile HTML's leadImage meta property tag reflects the media list's item ordering, such that the first item in the media list and the leadImage property value are the same value if the article has a lead image. (case 1)
  4. Stretch goal: the media list includes a per item leadImage boolean flag to reflect if this item is the lead image or not.

I imagine we'll also have to update the iOS client to completely remove the unexpected behavior, but first want to iron out any unexpected behavior with these endpoints. Please let me know if there are any more details I can provide!

Event Timeline

LGoto triaged this task as Low priority.Dec 3 2020, 8:46 PM