This is Where does the chat get the thumbnail on Wikipedia links from? turned into a bug post

Someone was complaining their head felt heavy in chat so I decided to link them to a possible solution:

enter image description here

The butterfly image is located near the bottom of the page; it is the image used for the Psychiatry portal.

There are also other unfortunate examples of image selection, e.g. Engineering.

The picture chosen for Mr. Miyagi is actually of Mr. Han from the 2010 remake.

The criteria for selecting images seems way off, why can't it just select it by the highest image as displayed; not the source image size? If it picked the one with the largest height or width tag in the HTML, that seems like it would be much better. If it uses some Wikipedia API, is there some way to just look at the article's 'source' page to determine it? Does the one-boxifier go out to every image and examine it?

  • It is on the page, at the very bottom. It's the picture used for the Psychiatry portal.
    – Wipqozn
    Aug 20, 2011 at 16:01
  • 1
    Picking the first image certainly is not the solution. Or do you think this image is a good representation of Anonymous?
    – balpha StaffMod
    Aug 20, 2011 at 16:13
  • Another bad case is any Greek letter. It shows the Phoenician letter it descended from, rather than the Greek letter that was linked. Feb 15, 2013 at 7:45

4 Answers 4


Wikipedia has an API method that attempts to return the best image for a page. It might be worth investigating using that to select the image.

  • 1
    Good tip, thank you. We're using that now; see my updated answer.
    – balpha StaffMod
    Jul 21, 2014 at 14:35

Using svick's tip, I've tried both my old image picking alorithm and Wikipedia's PageImages API side-by-side on a bunch of pages. The API version isn't perfect (see these messages – the first, clearly better, onebox was rendered with the old version, the second one with the PageImages API), but overall in my testing it seemed to come out ahead, so I've switched to the PageImages version.

I'll thus call this now, even though it still doesn't always pick the correct image by our definition. But since the API description says that the "aim is to return the single most appropriate thumbnail associated with an article", maybe over time their choice algorithm will be improved, and we would benefit from that automatically.

Original answer:

I just did some "random article" clicking on Wikipedia. Of all articles that even oneboxed with an image, the 16th one was the first one where a different image would absolutely have been better.

Wikipedia oneboxes

– and even that one isn't problematic. Yes, there are a few examples where the chosen image is certainly wrong. But until wikipedia has an API that gives you the canonical image for an article, there'll always be some sort of guesswork involved. The infobox suggestion might work, but we'll have to look closer at that before I can say that it's workable; a) we don't look at the HTML, and b) not all pages have an infobox.

Bottom line: tweaking is certainly a thing we can do, but it has to be within reason. It's not like this is a problem of extraordinary magnitude, and (unless we stop showing images altogether), there'll always be wrong choices.

  • 4
    Not that I'm sure this is an issue worth the developer time, but how about letting the user choose when they create the link? It's how Facebook does it, and it works nicely.
    – Pekka
    Aug 20, 2011 at 17:25
  • 1
    How about if you simply picked the first image in the HTML after <img class="thumbimage" ? That would be a huge improvement. To be honest, people are complaining about this all the time in English chat. Consider subtle but all the more misleading errors like this one: Protura. It would be really cool if this could be fixed at some point! Jan 13, 2013 at 4:37
  • Here is another example: Middle Earth is an aeroplane...it happens all the time, almost every other picture is wrong that we see in EL&U. Jan 14, 2013 at 4:17
  • @Cerberus Let's stay with the truth, okay?
    – balpha StaffMod
    Jan 14, 2013 at 8:39
  • @balpha: Okay, perhaps not every other picture...but it feels like every other! hands on hips Perhaps we should make a Greasemonkey script, then. Shouldn't be hard, I think (except that I'm a total layman). Jan 14, 2013 at 10:17
  • Yay!! This is a huge improvement, thank you very much! I can't wait to one-box Lobotomy all over the rooms! We probably can't do better than Wikipaedia's own algorisms, and we will benefit automatically from when they improve them, as you say. So this seems like the best option. <dances from chat room to chat room exhilaratedly> Jul 21, 2014 at 14:44
  • 1
    If there is some pattern with the images PageImages chooses incorrectly, it might make sense to report it.
    – svick
    Jul 21, 2014 at 14:44

It's not a perfect solution, but I'd suggest that if the page contains an infobox, which in turn contains an image, that one should take precedence.

The infobox is always denoted by <table class="infobox" ...>

That would have produced a correct or at least reasonable selection for all of the subjects mentioned so far, including balpha's Anonymous counterexample in the comments.

Failing that, it's pretty much luck of the draw.


Linking to The Treachery of Images gives a picture of a neuron, rather than the main image in question:

Ceci n'est un neurone.

The Treachery of Images The Treachery of Images (La trahison des images, 1928–29, sometimes translated as The Treason of Images) is a painting by the Belgian René Magritte, painted when Magritte was 30 years old. ...

This is not a pipe.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .