![]() | This proposal is part of "A Dozen Visions for Wikitext". Shortcuts: Versioning - Grunge - Markdown - HTML-only wikis - Extension tag fragments - Syntax uniformity - Colon replacement - Backticks - Syntax for Discussions - #media - #lang - #balance - Long arguments - Variable-length/structured arguments - Annotations - Visual Templates - Page Description Language - Native Script Editing - One Wiki |
{{#media}}
{{#media}}
You might have noticed {{#media}}
on previous proposals. It turns out that the existing [[File:...]]
syntax is really gross. One particular misfeature is that any unknown option is treated as a caption, so you can’t safely add or remove options without potentially affecting captions.
But it also turns out that “put this image exactly at this point and exactly XYZ pixels in size” isn’t really what you want with media, and that there’s a lot of semantic information we’d like to include but isn't present in the current syntax (phab:T90914). Finally, we have non-media content like graphs, charts, maps, and pull quotes that we want to be able to style just like the “built-in” media.
So here’s some syntax for a new {{#media}}
parser function to address those gaps. We add a style
option, where we can specify a semantic style for the image, like “this is a lead image” or “this image should be full width”, and we require an explicit named caption
argument.
{{#media:src=Foo.jpg|style=thumb|caption=...}} <!-- matches current defaults -->
{{#media:src=Foo.jpg|style=largethumb|...}} <!-- some wikis have a "large thumb" style -->
{{#media:src=Foo.jpg|style=fullwidth|...}}
{{#media:src=Foo.jpg|style=leadimage|...}}
We could also add focal point information so that we can more intelligently crop and resize images for different platforms. This could have a default focus derived from annotations in commons, but an image depicting multiple subjects might need the focus overridden in an article:
{{#media:src=Eiffel Tower|focus=50 75}} <!-- percent width, height -->
There’s a sample catalog of styles collected by User:MGalloway (WMF), although the exact mechanism by which local wikis define, extend, and localize semantic styles is still an open question. The strawdog proposal in phab:T90914 uses data in the MediaWiki:
namespace, but invoking a Scribunto module of a given name might allow better integration with the localization provided by the Plan for Scribunto proposal.
To address the issue of non-media content styled similarly to media, we also allow content=
as an alternative to src=
.
{{#media:content=<<<...>>>|caption=...}}
This allows user-generated content like maps and charts that can be styled the same way media is.
In Page Description Language we discuss further how media may be composed into the page, and perhaps {{#media}}
is just a stopgap until we remove media from the page flow entirely. As a transitional step to the future, however, we should start considering the semantic information that would be necessary to place media in a page description language and allow editors to record that information in the wikitext.
Next section: {{#lang}}