Add a REST endpoint at /v1/file/{title}/thumbnails that returns the standard public thumbnail derivatives available for a file.
Problem
MediaWiki already exposes file information through REST, but thumbnail discovery is still mostly tied to broader imageinfo behavior. For clients that only need public thumbnail variants, that is more complex than necessary and not ideal for a cache-friendly REST interface.
We want a dedicated endpoint with:
- deterministic, public-only output
- better cacheability
- explicit REST error handling
- a simpler service surface for thumbnail consumers
Proposed / Implemented shape
The endpoint returns:
- the file title
- a minimal original object for context
- a thumbnails array listing standard acceptable thumbnail variants
It does not support arbitrary width/height/urlparam input. It is intentionally limited to public thumbnail variants derived from configured thumbnail steps.
Example response:
json
{
"title": "Example.jpg",
"original": {
"mediatype": "BITMAP",
"width": 1200,
"height": 800,
"url": "https://example.org/wiki/Special:FilePath/Example.jpg"
},
"thumbnails": [
{
"width": 120,
"height": 80,
"url": "https://example.org/w/images/thumb/a/ab/Example.jpg/120px-Example.jpg",
"mime": "image/jpeg",
"responsive_urls": {
"2": "https://example.org/w/images/thumb/a/ab/Example.jpg/240px-Example.jpg"
}
},
{
"width": 250,
"height": 167,
"url": "https://example.org/w/images/thumb/a/ab/Example.jpg/250px-Example.jpg",
"mime": "image/jpeg"
}
]
}Why this is useful
Better cacheability
The response is deterministic for a given file and avoids user-specific sizing or privileged data. That makes it a better fit for shared caching and simpler validator-based revalidation using file-backed ETag / Last-Modified.
Better error handling
The endpoint can explicitly represent common failure cases instead of requiring clients to infer them indirectly:
- 400 for non-thumbnailable files
- 403 for unreadable files
- 404 for unresolved titles/files
Better service surface
Clients that only need public thumbnail options get a dedicated endpoint without needing to understand broader imageinfo transform behavior or request custom transform parameters.
Scope
This endpoint is intentionally public-only:
- no arbitrary transform parameters
- no user-preference-dependent thumbnail sizing
- no privileged metadata
- no revision/archive history traversal
Additional work included
- OpenAPI schema for the success response
- explicit OpenAPI error response documentation
- schema examples for client consumers
- integration coverage for the new handler