MediaViewer has a caption and description area (above and below the fold, respectively) with the following logic:
- caption: thumbnail caption; if missing or not viewing a thumbnail, description from the Information template on the file page; if also missing, file name
- description: description from the Information template on the file page, unless it's already shown as a caption; otherwise empty.
Now that we have captions via Structured Data on Comons, we should pass those along and the logic for the caption should probably be something like:
thumbnail caption; if missing or not viewing a thumbnail, caption from structured data; if also missing (*), description from the Information template on the file page; if also missing, file name
(*) language fallbacks for similar languages could be applied here, since captions are multilingual, but probably better not to try that. We don't do it for descriptions either.
This is a bit more complicated than it seems and would probably involve figuring out a way to fetch the caption for each of the File subclasses. See T213585: Images (on articles, on file/category pages, and in the media viewer) should default to use their structured data alt text when available which describes the same problem for a different structured data field.