diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 30b8250764e..a2a73fd43d4 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -4927,11 +4927,12 @@ $wgAllowImageTag = false; $wgTidyConfig = []; /** - * Emit using the new media structure described at, + * Enable legacy media HTML structure in the output from the Parser. The one + * that replaces it is described at, * https://www.mediawiki.org/wiki/Parsing/Media_structure * @since 1.36 */ -$wgUseNewMediaStructure = false; +$wgParserEnableLegacyMediaDOM = true; /** * Allow raw, unchecked HTML in "..." sections. diff --git a/includes/Linker.php b/includes/Linker.php index 79c7232ba06..00be6c204c5 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -331,13 +331,24 @@ class Linker { $frameParams['class'] = ''; } + $services = MediaWikiServices::getInstance(); + $enableLegacyMediaDOM = $services->getMainConfig()->get( 'ParserEnableLegacyMediaDOM' ); + + $classes = []; + if ( !isset( $handlerParams['width'] ) ) { + $classes[] = 'mw-default-size'; + } + $prefix = $postfix = ''; - if ( $frameParams['align'] == 'center' ) { - $prefix = '
















+

[[]] +
+!! end + +!! test +Image with link trail +!! config +wgParserEnableLegacyMediaDOM=false +!! wikitext +Linktrails should not work for images: [[File:Foobar.jpg]]s +!! html/php +Linktrails should not work for images:
s
+
Linktrails should not work for images:
s










+123

456 +123

456
+!! html/parsoid + +123

456 +123

456
+!! end + +!! test +Image with multiple captions -- only last one is accepted +!! config +wgParserEnableLegacyMediaDOM=false +!! wikitext +[[File:Foobar.jpg|right|Caption1 - ignored|[[Caption2]] - ignored|Caption3 - accepted]] +!! html/php +









+

















































Image:test +!! wikitext +[[:Image:test]] +!! html +
+!! end + +!! test +T20784 Link to non-existent image page with caption should use caption as link text +!! wikitext +[[:Image:test|caption]] +!! html +caption +
+!! end + +!! test +Frameless image caption with a free URL +!! config +wgParserEnableLegacyMediaDOM=false +!! wikitext +[[File:Foobar.jpg|http://example.com]] +!! html/php + +!! html/parsoid + +!! end + +!! test +Thumbnail image caption with a free URL +!! options +thumbsize=220 +!! config +wgParserEnableLegacyMediaDOM=false +!! wikitext +[[File:Foobar.jpg|thumb|http://example.com]] +!! html/php +















[[Image:Foobar.jpg|thumb|This is a broken caption. But this is just an ordinary link. +
+!! html/parsoid +[[Image:Foobar.jpg|thumb|This is a broken caption. But this is just an ordinary link.
+!! end + +!! test +Image caption containing another image +!! config +wgParserEnableLegacyMediaDOM=false +!! wikitext +[[File:Foobar.jpg|thumb|This is a caption with another [[File:Thumb.png|image]] inside it!]] +!! html/php +
inside it!
inside it!

| Foo | Bar |
|---|---|
| Foo1 | +Bar1 |



















| a | b |
| c |

foo
+
bar
+!! end + +!! test +Parsoid-specific image handling - empty caption (1) +!! options +parsoid=wt2html,wt2wt +!! wikitext +[[File:Foobar.jpg|thumb|]] +!! html/parsoid +
+
+ 
File:Foo's italic bar.jpg +File:Foo's italic bar.jpg +
+!! end + +!! test +Broken image links with HTML captions (T41700) +!! config +wgParserEnableLegacyMediaDOM=false +!! wikitext +[[File:Nonexistent|]] +[[File:Nonexistent|100x100px|]] +[[File:Nonexistent|<]] +[[File:Nonexistent|abc]] +!! html/php +File:Nonexistent +File:Nonexistent +File:Nonexistent +File:Nonexistent +
+!! html/parsoid +File:Nonexistent +File:Nonexistent +File:Nonexistent +File:Nonexistent
+!! end + +!! test +Media in wikilink +!! config +wgParserEnableLegacyMediaDOM=false +!! wikitext +[[Test|[[File:Foobar.jpg]]]] +!! html/php + +!! html/parsoid + +!! end + +!! test +Template with thumb image (with link in description) +!! config +wgParserEnableLegacyMediaDOM=false +!! wikitext +{{paramtest|param=[[Image:noimage.png|thumb|[[no link|link]] [[no link|caption]]]]}} +!! html/php+untidy +This is a test template with parameter +!! html+tidy +This is a test template with parameter
This is a test template with parameter
centre ++
caption +
+some caption Main Page +
+caption +
+some caption Main Page +
+

Nonexistent.jpg +caption +
+Foobar.jpg +some caption Main Page +
+hi
ho












File:Contains & ampersand.jpg +File:Does not exist.jpg +
+!! html/parsoid +File:Contains & ampersand.jpg +File:Does not exist.jpg
+!! end + +# T65642/T68749: Formatting elt fixup around images. +# We know wt2wt will fail, but we expect selser to pass. +# Due to the nature of our testing, wt2wt and selser tests will enter the +# banned list and we'll catch selser regressions based on changes to the +# banned list entries for selser tests. +!! test +1. Treebuilder fixup of formatting elt +!! options +parsoid=wt2html,wt2wt +!! config +wgParserEnableLegacyMediaDOM=false +!! wikitext +{| +| + +[[Image:Foobar.jpg|right|Test]] + +|} +!! html/php+tidy +|
+ + +![]() + + |
+
+![]() |
foo

bar +

foo

bar
+ +
foo

bar
+!! html/parsoid +foo

bar
+!! end + +!! test +4. Treebuilder fixup of formatting elt: formatting tags around captionless images +!! options +parsoid=wt2html,wt2wt +!! config +wgParserEnableLegacyMediaDOM=false +!! wikitext +'''[[Image:Foobar.jpg|right|300px]]''' +!! html/php+tidy +




123
+
456
+!! end + +!! test +Image: New block level image should have \n before and after (existing content) +!! wikitext +123 +[[File:Foobar.jpg|right|thumb|150x150px]] +456 +!! html/parsoid +123
+
456
+!! end + +!! test +Image: upright option (parsoid) +!! wikitext +[[File:Foobar.jpg|thumb|upright|caption]] +[[File:Foobar.jpg|thumb|upright=0.5|caption]] +[[File:Foobar.jpg|thumb|500x500px|upright=0.5|caption]] +!! html/parsoid +



+
+!! wikitext
+[[File:Foobar.jpg|link=|alt=Alt|100x100px]]
+!! end
+
+!! test
+Image: from basic HTML (2)
+!! options
+parsoid=html2wt
+!! html/parsoid
+
+!! wikitext
+[[File:Foobar.jpg|link=|alt=Alt|100x100px]]
+!! end
+
+!! test
+Image: from basic HTML (3)
+!! options
+parsoid=html2wt
+!! html/parsoid
+
+!! wikitext
+[[File:Foobar.jpg|link=Main|alt=Alt|100x100px]]
+!! end
+
+!! test
+Image: from basic HTML (4)
+!! options
+parsoid=html2wt
+!! html/parsoid
+
+!! wikitext
+[[File:Foobar.jpg|link=]]
+!! end
+
+!! test
+Image: Invalid title as link
+!! config
+wgParserEnableLegacyMediaDOM=false
+!! wikitext
+[[File:Foobar.jpg|link=<]]
+!! html/php
+
+!! html/parsoid
+
+!! end
+
+!! test
+Various link types in alt and link options
+!! config
+wgParserEnableLegacyMediaDOM=false
+!! wikitext
+[[File:Foobar.jpg|link=[[Main Page]]|alt=[[Main Page]]|caption]]
+
+[[File:Foobar.jpg|link=[[Media:Thumb.png]]|alt=[[Media:Thumb.png]]|caption]]
+
+[[File:Foobar.jpg|link=[[wikipedia:Foo]]|alt=[[wikipedia:Foo]]|caption]]
+!! html/php+tidy
+
+!! html/parsoid
+
+
+
+
+
+!! end
+
+!! test
+Magic links inside image captions (autolinked)
+!! config
+wgParserEnableLegacyMediaDOM=false
+!! wikitext
+[[File:Foobar.jpg|thumb|http://example.com]]
+[[File:Foobar.jpg|thumb|RFC 1234]]
+[[File:Foobar.jpg|thumb|PMID 1234]]
+[[File:Foobar.jpg|thumb|ISBN 123456789x]]
+!! html+tidy
+













File:Denys Savchenko Pentecoste.jpg +
File:Denys Savchenko Pentecoste.jpg
Pentecoste @@ -18383,13 +18385,15 @@ all additional text is vanished Language converter glossary rules inside attributes (T119158) !! options language=sr variant=sr-el +!! config +wgParserEnableLegacyMediaDOM=false !! wikitext -{H|foAjrjvi=>sr-el:" onload="alert(1)" data-foo="}- [[File:Foobar.jpg|alt=-{}-foAjrjvi-{}-]] !! html/php
-
!! html/parsoid @@ -22904,6 +22908,8 @@ name= Page status indicators: Torture test !! options showindicators +!! config +wgParserEnableLegacyMediaDOM=false !! wikitextUser:+% Page+title% %+ %20 %+ %+r -% + bar +% + File:%+abc9 3E 3E+
!! html/parsoid @@ -23255,6 +23263,8 @@ __TOC__ T35845: Headings become cursive in TOC when they contain an image !! options title=[[Main Page]] +!! config +wgParserEnableLegacyMediaDOM=false !! wikitext __TOC__ ==Image [[Image:foobar.jpg]]== @@ -23265,7 +23275,7 @@ __TOC__ -
[edit]
[edit]