Steps to replicate the issue (include links if applicable):
- Make sure your Preferences are set to English
- Open https://commons.wikimedia.org/wiki/File:Bodegas_de_Mile%C8%99tii_Mici,_Moldavia,_2023-11-02,_DD_74.jpg
- Click 'Open in Media Viewer' and check what appears as the image caption
What happens?:
The caption is 'This file illustrates a cultural heritage monument in Moldova, ID'
What should have happened instead?:
Caption should be 'Wine cellars of Mileștii Mici, Chișinău, Moldova' because {{information}} is:
{{Information |description={{en|1=Wine cellars of Mileștii Mici, Chișinău, Moldova}} {{Monument ocrotit de stat|MD-IL-Is-N-0738}} |date=2023-11-02 20:44:18
Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia): It's Wikimedia Commons
Other information (browser name/version, screenshots, etc.):
Tested on Firefox 132, but it's not related to browser. The caption comes from query -> pages -> iageinfo -> extmetadata -> ImageDescription returned by api.php?action=query&format=json&formatversion=2&prop=imageinfo
Other affected areas:
- description shown in the right sidebar when you use 'search' field on Commons and click a single search result https://commons.wikimedia.org/wiki/Special:MediaSearch?type=image&search=bodegas+Mile%C8%99tii
- descriptions shown on Commons POTY voting page
It also breaks correct 'Captions' metadata provided on Commons. If you have a caption, and description= field is empty, Media Viewer correctly uses the caption. But I saw files where a caption was given but 'description' was just a template on cultural heritage. Or sometimes just {{Commonist}}. With such a form of 'description', Media Viewer replaces the useful caption with a generic text about cultural heritage, or even displays blank caption.
Surprisingly, there are cases where a template is used in the description= field, but the ImageDescription extracted by the API is correct. See https://commons.wikimedia.org/wiki/File:Nikiszowiec,_courtyard_with_chimneys,_2024-08-09.jpg.
It's hard to understand why 2 files with similar wikicode inside {{information}} give drastically different results in the result of extracted ImageDescription. It would be good if there is a documentation targetted to users not familiar with MediaWiki internals of how ImageDescription extraction works: what is allowed inside description= wikicode and what should be allowed.
The bug was discussed on Wikimedia Commons: https://commons.wikimedia.org/wiki/Commons:Village_pump/Technical/Archive/2024/10#Templates_in_description_field_cause_empty_caption_in_Media_Viewer
You can find a few more 'test cases' there.