Currently images uses the filename as alt text both on file/category pages, in the media viewer, and in article thumbnails where an alt text is not manually specified. These should use a centrally provided default alt text, once that's implemented (via T166094: Allow editors to provide default alt text on Wikimedia Commons file description pages, extra credit if the mechanism is easy to make work for an alternative non-Wikibase-based implementation such as T21906: Allow default alternate text for images to be provided on the file description page too).
This would involve, at least:
- making it possible to get the alt text of a File object (or maybe its structured data more generally - but then for foreign repos we'd have to deal with serialization/deserialization, which would probably result in requiring Wikibase in the client wiki, which is a bad outcome so better to just stick with the alt text; that also shields clients from having to parse the exact structured data model we use, which might change over time)
- for LocalFile this should be straightforward via MCR
- for ForeignAPIFile (InstantCommons) this would require exposing the data in the imageinfo API (the other option would be combining imageinfo with some Wikibase API, but since we can't rely on Wikibase being installed in all foreign image repos, that would make things a lot more complicated)
- for ForeignDBFile, maybe rely on MCR but deserialize the content object on the wiki where the thumbnail is used (seems scary) or put the alt text in some dedicated place in the DB (page_props is used for similar things such as Wikidata descriptions, but it's multilingual so that wouldn't really work) or do a dedicated API call (we already do a HTTP request for fetching file descriptions, but those are cached in Varnish and the API isn't)? None of those options sound good.
- displaying the default alt text in ThumbnailImage::toHtml() if an explicit alt text is not passed in the options (and also probably depending on the custom-*-link options - if this images is used as a navigational or decorative element we might want to suppress the alt text), probably by passing it in File::transform() when creating the ThumbnailImage object.
- making sure it's not overridden with something less specific (e.g. ImagePage::view() passes in the filename as alt parameter now)
- exposing the data in the imageinfo API and using it in MediaViewer