Links to Mediawiki image pages (HTML) break in oneboxes

This is a problem created by Mediawiki’s bad URL structure, but it happens occasionally on my sites.

The URL of an HTML page for an image on Wikipedia works:

If I paste this URL below without backticks, it will create a onebox (wrong title, but at least the link works):
https://en.wikipedia.org/wiki/Main_Page#/media/File:ESO_Centaurus_A_LABOCA.jpg

Result:

If I do it with another Mediawiki site like this URL, it breaks the onebox:
https://fortnite.fandom.com/wiki/Fortnite:_Save_the_World?file=Update+v40.20+-+Cover+Art+-+Save+the+World.jpg

Result:

Maybe it could be fixed by checking the Content-Type in the response for text/html? If it is, then don’t treat it as an image?

3 likes