In order to be able to stop shipping the older styles in `content.thumbnails-*.less`, content that's mimicking the parser media output needs to be migrated to the new structure.
However, the styles in `content.media-*.less` are targeted towards `typeof="mw:File"` annotations, which might not make sense semantically for that content (and would likely be [[ https://github.com/wikimedia/parsoid/blob/master/src/Wt2Html/TokenizerUtils.php#L443-L457 | sanitized away ]]). Perhaps we need to add a class in the stylesheet for this content to target instead? But note that, in T314097, it was discouraged to add a classes that MediaWiki core isn't generating:
> I don't think it makes sense to put a class here that's not generated by MediaWiki core however. At the very least not without a huge inline comment explaining why.
From https://gerrit.wikimedia.org/r/c/mediawiki/core/+/812384/7#message-a49f26cd09eb71d8f23b950b91f63359a938e370
---
>>! In T297447#8242819, @Tacsipacsi wrote:
> Templates can also produce legacy DOM, expecting the skin to style it (e.g. [[https://hu.wikipedia.org/wiki/Sablon:Sz%C3%A9les_k%C3%A9p|hu:Sablon:Széles kép]]), and/or consume the DOM using TemplateStyles. These also need to be checked, and I think they could be in the scope of this ticket.
---
>>! In T297447#8247013, @Arlolra wrote:
>> This particular example should be unaffected since, for the moment, we aren't removing the old styling rules. But, yes, getting all the on wiki content that mimics the parser output ported to the new styling rules will be a longer term goal.
>
> https://en.wikipedia.org/wiki/Template:Multiple_image looks like another one
---
>>! In T271114#8247024, @Arlolra wrote:
>> .mw-kartographer-container.thumb:not(.mw-kartographer-full) .thumbinner > .mw-kartographer-map {
>
> In T272186, we looked at extensions that needed updating for the new structure, but Kartographer wasn't one of them. It looks like it's doing something similar to what some templates do (see T297447#8242965) and tries to mimic the legacy media structure that the parser outputs, to reuse the styling,
> https://github.com/wikimedia/mediawiki-extensions-Kartographer/blob/master/includes/Tag/MapFrame.php#L191
> https://github.com/wikimedia/mediawiki-extensions-Kartographer/blob/master/styles/kartographer.less#L117-L158
>
> That should continue to work, since we aren't yet removing those styles, but should eventually maybe be migrated the new styles and structure.
**EDIT: from T318433#10397735 below:**
We discussed this task during MW engineering offsite. Proposed solution, inspired by T204370, is to add a new parser function {{#media}}, which in its full form will be a replacement for `[[File:]]` syntax, but with cleaner option handling (eg, requiring `caption=....` instead of parsing any unrecognized option as the caption). `{{#media|src=Foo.jpg}}` would be the equivalent of `[[File:Foo.jpg]]` but instead of `src` you could pass `content=...` as an option to embed arbitrary user-generated content, using the structure described above in:
>>! In T318433#8680937, @cscott wrote:
> ```
> <figure typeof="mw:Transclusion mw:File" ...>
> <a href="..."><span typeof="mw:UserContent">...parsed user wikitext...</span></a>
> <figcaption typeof="mw:UserContent">...parsed user wikitext...</figcaption>
> </figure>
> ```
> That would enforce the expected DOM structure on the user content and allow the reuse of `typeof=mw:File` in a safe (parser-generated typeof, not user-controlled) way. And, of course, if we ever made future tweaks to the media styling or DOM structure, we can make them in a single place in the `{{#figure}}` implementation and have them applied uniformly to user-generated content.
(We probably don't actually need `typeof=mw:UserContent` on the figcaption, since the caption is always user-generated content; this isn't new in any way.)
The implementation should call an Parsoid API in order to share as much code as possible with the existing Parsoid image handling code.