/
media.txt
4454 lines (4112 loc) · 379 KB
/
media.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
!! options
version=2
parsoid-compatible=wt2html,wt2wt
!! end
!! article
Main Page
!! text
blah blah
!! endarticle
!! article
Foo''s bar''s
!! text
Article titles can contain single quotes!
!! endarticle
!! article
Template:1x
!! text
{{{1}}}
!! endarticle
!! article
Template:image_attribs
!! text
<noinclude>
[[File:foobar.jpg|</noinclude>right|Caption text<noinclude>]]</noinclude>
!! endarticle
!! article
Template:paramtest
!! text
This is a test template with parameter {{{param}}}
!! endarticle
!! article
Template:test
!! text
This is a test template
!! endarticle
!! article
MediaWiki:bad image list
!! text
* [[File:Bad.jpg]] except [[Nasty page]]
!! endarticle
!! article
File:Redirect to foobar.jpg
!! text
#REDIRECT[[File:Foobar.jpg]]
!! endarticle
###
### Images
###
### For Parsoid-specific tests, see
### https://www.mediawiki.org/wiki/Specs/HTML#Images
!! test
Simple image
!! options
parsoid=wt2html,wt2wt,html2html
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[Image:foobar.jpg]]
!! html/php
<p><span class="mw-default-size" typeof="mw:File"><a href="/wiki/File:Foobar.jpg" class="mw-file-description"><img src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" class="mw-file-element" /></a></span>
</p>
!! html/parsoid
<p><span class="mw-default-size" typeof="mw:File"><a href="./File:Foobar.jpg" class="mw-file-description"><img resource="./File:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" class="mw-file-element"/></a></span></p>
!! end
!! test
Simple image redirect
!! options
parsoid=wt2html,wt2wt,html2html
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[Image:Redirect to foobar.jpg]]
!! html/php
<p><span class="mw-default-size" typeof="mw:File"><a href="/wiki/File:Foobar.jpg" class="mw-file-description"><img src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" class="mw-file-element" /></a></span>
</p>
!! html/parsoid+integrated
<p><span class="mw-default-size" typeof="mw:File"><a href="./File:Foobar.jpg" class="mw-file-description"><img resource="./File:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" class="mw-file-element"/></a></span></p>
!! end
!! test
Serialize simple image with figure-inline wrapper
!! options
parsoid=html2wt
!! html/parsoid
<p><figure-inline class="mw-default-size" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" class="mw-file-element"/></a></figure-inline></p>
!! wikitext
[[File:Foobar.jpg]]
!! end
!! test
Serialize simple image with mw:Image typeof
!! options
parsoid=html2wt
!! html/parsoid
<p><span class="mw-default-size" typeof="mw:Image"><a href="./File:Foobar.jpg" class="mw-file-description"><img resource="./File:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" class="mw-file-element"/></a></span></p>
!! wikitext
[[File:Foobar.jpg]]
!! end
!! test
Simple image (using File: namespace, now canonical)
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg]]
!! html/php
<p><span class="mw-default-size" typeof="mw:File"><a href="/wiki/File:Foobar.jpg" class="mw-file-description"><img src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" class="mw-file-element" /></a></span>
</p>
!! html/parsoid
<p><span class="mw-default-size" typeof="mw:File"><a href="./File:Foobar.jpg" class="mw-file-description"><img resource="./File:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" class="mw-file-element"/></a></span></p>
!! end
!! test
Right-aligned image
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|right]]
!! html/php
<figure class="mw-default-size mw-halign-right" typeof="mw:File"><a href="/wiki/File:Foobar.jpg" class="mw-file-description"><img src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" class="mw-file-element" /></a><figcaption></figcaption></figure>
!! html/parsoid
<figure class="mw-default-size mw-halign-right" typeof="mw:File"><a href="./File:Foobar.jpg" class="mw-file-description"><img resource="./File:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" class="mw-file-element"/></a><figcaption></figcaption></figure>
!! end
!! test
Image with caption
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|right|Caption text]]
!! html/php
<figure class="mw-default-size mw-halign-right" typeof="mw:File"><a href="/wiki/File:Foobar.jpg" class="mw-file-description" title="Caption text"><img alt="Caption text" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" class="mw-file-element" /></a><figcaption>Caption text</figcaption></figure>
!! html/parsoid
<figure class="mw-default-size mw-halign-right" typeof="mw:File"><a href="./File:Foobar.jpg" class="mw-file-description" title="Caption text"><img alt="Caption text" resource="./File:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" class="mw-file-element"/></a><figcaption>Caption text</figcaption></figure>
!! end
!! test
Image with caption, T55312 #1
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|right|Caption page stuff]]
!! html/php
<figure class="mw-default-size mw-halign-right" typeof="mw:File"><a href="/wiki/File:Foobar.jpg" class="mw-file-description" title="Caption page stuff"><img alt="Caption page stuff" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" class="mw-file-element" /></a><figcaption>Caption page stuff</figcaption></figure>
!! html/parsoid
<figure class="mw-default-size mw-halign-right" typeof="mw:File"><a href="./File:Foobar.jpg" class="mw-file-description" title="Caption page stuff"><img alt="Caption page stuff" resource="./File:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" class="mw-file-element"/></a><figcaption>Caption page stuff</figcaption></figure>
!! end
!! test
Image with caption, T55312 #2
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|right|Caption page=]]
!! html/php
<figure class="mw-default-size mw-halign-right" typeof="mw:File"><a href="/wiki/File:Foobar.jpg" class="mw-file-description" title="Caption page="><img alt="Caption page=" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" class="mw-file-element" /></a><figcaption>Caption page=</figcaption></figure>
!! html/parsoid
<figure class="mw-default-size mw-halign-right" typeof="mw:File"><a href="./File:Foobar.jpg" class="mw-file-description" title="Caption page="><img alt="Caption page=" resource="./File:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" class="mw-file-element"/></a><figcaption>Caption page=</figcaption></figure>
!! end
!! test
Image with caption, T55312 #3
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|right|Caption page=stuff]]
!! html/php
<figure class="mw-default-size mw-halign-right" typeof="mw:File"><a href="/wiki/File:Foobar.jpg" class="mw-file-description" title="Caption page=stuff"><img alt="Caption page=stuff" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" class="mw-file-element" /></a><figcaption>Caption page=stuff</figcaption></figure>
!! html/parsoid
<figure class="mw-default-size mw-halign-right" typeof="mw:File"><a href="./File:Foobar.jpg" class="mw-file-description" title="Caption page=stuff"><img alt="Caption page=stuff" resource="./File:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" class="mw-file-element"/></a><figcaption>Caption page=stuff</figcaption></figure>
!! end
!! test
Image caption with pipe entity
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|thumb|one | two]]
[[File:Foobar.jpg|thumb|one ''two'' | three]]
!! html/php
<figure class="mw-default-size" typeof="mw:File/Thumb"><a href="/wiki/File:Foobar.jpg" class="mw-file-description"><img src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" decoding="async" width="180" height="20" class="mw-file-element" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a><figcaption>one | two</figcaption></figure>
<figure class="mw-default-size" typeof="mw:File/Thumb"><a href="/wiki/File:Foobar.jpg" class="mw-file-description"><img src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" decoding="async" width="180" height="20" class="mw-file-element" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a><figcaption>one <i>two</i> | three</figcaption></figure>
!! html/parsoid
<figure class="mw-default-size" typeof="mw:File/Thumb"><a href="./File:Foobar.jpg" class="mw-file-description"><img resource="./File:Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="20" width="180" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" class="mw-file-element"/></a><figcaption>one <span typeof="mw:Entity">|</span> two</figcaption></figure>
<figure class="mw-default-size" typeof="mw:File/Thumb"><a href="./File:Foobar.jpg" class="mw-file-description"><img resource="./File:Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="20" width="180" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" class="mw-file-element"/></a><figcaption>one <i>two</i> <span typeof="mw:Entity">|</span> three</figcaption></figure>
!! end
!! test
Bad images - basic functionality
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Bad.jpg]]
!! html/php
<p><span class="mw-default-size" typeof="mw:Error mw:File"><a href="/wiki/File:Bad.jpg" title="File:Bad.jpg"><span class="mw-file-element mw-broken-media" data-width="320">File:Bad.jpg</span></a></span>
</p>
!! html/parsoid
<p><span class="mw-default-size" typeof="mw:Error mw:File" data-mw='{"errors":[{"key":"apierror-badfile","message":"This image is on the bad file list."}]}'><a href="./Special:FilePath/Bad.jpg"><span class="mw-file-element mw-broken-media" resource="./File:Bad.jpg">File:Bad.jpg</span></a></span></p>
!! end
!! test
Bad images - T18039: text after bad image disappears
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
Foo bar
[[File:Bad.jpg]]
Bar foo
!! html/php
<p>Foo bar
<span class="mw-default-size" typeof="mw:Error mw:File"><a href="/wiki/File:Bad.jpg" title="File:Bad.jpg"><span class="mw-file-element mw-broken-media" data-width="320">File:Bad.jpg</span></a></span>
Bar foo
</p>
!! html/parsoid
<p>Foo bar
<span class="mw-default-size" typeof="mw:Error mw:File" data-mw='{"errors":[{"key":"apierror-badfile","message":"This image is on the bad file list."}]}'><a href="./Special:FilePath/Bad.jpg"><span class="mw-file-element mw-broken-media" resource="./File:Bad.jpg">File:Bad.jpg</span></a></span>
Bar foo</p>
!! end
!! test
Bad images - manualthumb
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|thumbnail=Bad.jpg|Uh oh]]
!! html/php
<figure typeof="mw:Error mw:File/Thumb"><a href="/wiki/File:Foobar.jpg" title="File:Foobar.jpg"><span class="mw-file-element mw-broken-media" data-width="180">File:Foobar.jpg</span></a><figcaption>Uh oh</figcaption></figure>
!! html/parsoid
<figure typeof="mw:Error mw:File/Thumb" data-mw='{"attribs":[["manualthumb",{"txt":"Bad.jpg"}]],"errors":[{"key":"apierror-badfile","message":"This image is on the bad file list."}]}'><a href="./Special:FilePath/Foobar.jpg"><span class="mw-file-element mw-broken-media" resource="./File:Foobar.jpg">File:Foobar.jpg</span></a><figcaption>Uh oh</figcaption></figure>
!! end
!! test
Bad images - in gallery
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
<gallery>
File:Bad.jpg
</gallery>
!! html/php
<ul class="gallery mw-gallery-traditional">
<li class="gallerybox" style="width: 155px">
<div class="thumb" style="height: 150px;"><span typeof="mw:Error mw:File"><a href="/wiki/File:Bad.jpg" title="File:Bad.jpg"><span class="mw-file-element mw-broken-media" data-width="120" data-height="120">File:Bad.jpg</span></a></span></div>
<div class="gallerytext"></div>
</li>
</ul>
!! html/parsoid
<ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
<li class="gallerybox" style="width: 155px;"><div class="thumb" style="height: 150px;"><span typeof="mw:Error mw:File" data-mw='{"errors":[{"key":"apierror-badfile","message":"This image is on the bad file list."}]}'><a href="./Special:FilePath/Bad.jpg"><span class="mw-file-element mw-broken-media" resource="./File:Bad.jpg" data-width="120" data-height="120">File:Bad.jpg</span></a></span></div><div class="gallerytext"></div></li>
</ul>
!! end
!! article
Link1
!! text
Dummy article to suppress redlinks in tests
!! end
!! article
Link2
!! text
Dummy article to suppress redlinks in tests
!! end
!! test
Allow empty links in image captions (T62753)
!! options
thumbsize=220
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|thumb|Caption [[Link1]]
[[]]
[[Link2]]
]]
!! html/php
<figure class="mw-default-size" typeof="mw:File/Thumb"><a href="/wiki/File:Foobar.jpg" class="mw-file-description"><img src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" decoding="async" width="220" height="25" class="mw-file-element" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a><figcaption>Caption <a href="/wiki/Link1" title="Link1">Link1</a> [[]] <a href="/wiki/Link2" title="Link2">Link2</a></figcaption></figure>
!! html/parsoid
<figure class="mw-default-size" typeof="mw:File/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"caption","ak":"Caption [[Link1]]\n[[]]\n[[Link2]]\n"}]}'><a href="./File:Foobar.jpg" class="mw-file-description"><img resource="./File:Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"25","width":"220"},"sa":{"resource":"File:Foobar.jpg"}}' class="mw-file-element"/></a><figcaption>Caption <a rel="mw:WikiLink" href="./Link1" title="Link1" data-parsoid='{"stx":"simple","a":{"href":"./Link1"},"sa":{"href":"Link1"}}'>Link1</a>
[[]]
<a rel="mw:WikiLink" href="./Link2" title="Link2" data-parsoid='{"stx":"simple","a":{"href":"./Link2"},"sa":{"href":"Link2"}}'>Link2</a>
</figcaption></figure>
!! end
!! test
Titles in unlinked images (T23454)
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|link=|stuff]]
!! html/php
<p><span class="mw-default-size" typeof="mw:File"><span title="stuff"><img alt="stuff" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" class="mw-file-element" /></span></span>
</p>
!! html/parsoid
<p><span class="mw-default-size" typeof="mw:File" data-mw='{"caption":"stuff"}'><span title="stuff"><img alt="stuff" resource="./File:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" class="mw-file-element"/></span></span></p>
!! end
!! test
Unlinked media in gallery
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
<gallery>
File:Foobar.jpg|link=|stuff
</gallery>
!! html/php
<ul class="gallery mw-gallery-traditional">
<li class="gallerybox" style="width: 155px">
<div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:File"><span title="stuff"><img alt="stuff" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" decoding="async" width="120" height="14" class="mw-file-element" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></span></span></div>
<div class="gallerytext">stuff</div>
</li>
</ul>
!! html/parsoid
<ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:File"><span title="stuff"><img alt="stuff" resource="./File:Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" class="mw-file-element"/></span></span></div><div class="gallerytext">stuff</div></li>
</ul>
!! end
!! test
Link with empty target
!! wikitext
[[]]
!! html
<p>[[]]
</p>
!! end
!! test
Image with link trail
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
Linktrails should not work for images: [[File:Foobar.jpg]]s
!! html/php
<p>Linktrails should not work for images: <span class="mw-default-size" typeof="mw:File"><a href="/wiki/File:Foobar.jpg" class="mw-file-description"><img src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" class="mw-file-element" /></a></span>s
</p>
!! html/parsoid
<p>Linktrails should not work for images: <span class="mw-default-size" typeof="mw:File"><a href="./File:Foobar.jpg" class="mw-file-description"><img resource="./File:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" class="mw-file-element"/></a></span>s</p>
!! end
!! test
Image with empty attribute
!! options
parsoid=wt2html,wt2wt,html2html
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|right||Caption text]]
!! html/php
<figure class="mw-default-size mw-halign-right" typeof="mw:File"><a href="/wiki/File:Foobar.jpg" class="mw-file-description" title="Caption text"><img alt="Caption text" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" class="mw-file-element" /></a><figcaption>Caption text</figcaption></figure>
!! html/parsoid
<figure class="mw-default-size mw-halign-right" typeof="mw:File"><a href="./File:Foobar.jpg" class="mw-file-description" title="Caption text"><img alt="Caption text" resource="./File:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" class="mw-file-element"/></a><figcaption>Caption text</figcaption></figure>
!! end
!! test
1. Block image with individual attributes from templates
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|thumb|{{1x|137px}}|This is a caption]]
!! html/php
<figure typeof="mw:File/Thumb"><a href="/wiki/File:Foobar.jpg" class="mw-file-description"><img src="http://example.com/images/thumb/3/3a/Foobar.jpg/137px-Foobar.jpg" decoding="async" width="137" height="16" class="mw-file-element" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/206px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/274px-Foobar.jpg 2x" /></a><figcaption>This is a caption</figcaption></figure>
!! html/parsoid
<figure typeof="mw:File/Thumb mw:ExpandedAttrs" about="#mwt2" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"width","ak":"{{1x|137px}}"},{"ck":"caption","ak":"This is a caption"}]}' data-mw='{"attribs":[["width",{"html":"<span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid='{\"pi\":[[{\"k\":\"1\"}]]}' data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"1x\",\"href\":\"./Template:1x\"},\"params\":{\"1\":{\"wt\":\"137px\"}},\"i\":0}}]}'>137px</span>"}]]}'><a href="./File:Foobar.jpg" class="mw-file-description"><img resource="./File:Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/137px-Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="16" width="137" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/206px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/274px-Foobar.jpg 2x" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"16","width":"137"},"sa":{"resource":"File:Foobar.jpg"}}' class="mw-file-element"/></a><figcaption>This is a caption</figcaption></figure>
!! end
!! test
2. Block Image with individual attributes from templates
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|{{1x|thumb}}|{{1x|137px}}|This is a caption]]
!! html/php
<figure typeof="mw:File/Thumb"><a href="/wiki/File:Foobar.jpg" class="mw-file-description"><img src="http://example.com/images/thumb/3/3a/Foobar.jpg/137px-Foobar.jpg" decoding="async" width="137" height="16" class="mw-file-element" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/206px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/274px-Foobar.jpg 2x" /></a><figcaption>This is a caption</figcaption></figure>
!! html/parsoid
<figure typeof="mw:File/Thumb mw:ExpandedAttrs" about="#mwt3" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"{{1x|thumb}}"},{"ck":"width","ak":"{{1x|137px}}"},{"ck":"caption","ak":"This is a caption"}]}' data-mw='{"attribs":[["thumbnail",{"html":"<span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid='{\"pi\":[[{\"k\":\"1\"}]]}' data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"1x\",\"href\":\"./Template:1x\"},\"params\":{\"1\":{\"wt\":\"thumb\"}},\"i\":0}}]}'>thumb</span>"}],["width",{"html":"<span about=\"#mwt2\" typeof=\"mw:Transclusion\" data-parsoid='{\"pi\":[[{\"k\":\"1\"}]]}' data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"1x\",\"href\":\"./Template:1x\"},\"params\":{\"1\":{\"wt\":\"137px\"}},\"i\":0}}]}'>137px</span>"}]]}'><a href="./File:Foobar.jpg" class="mw-file-description"><img resource="./File:Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/137px-Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="16" width="137" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/206px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/274px-Foobar.jpg 2x" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"16","width":"137"},"sa":{"resource":"File:Foobar.jpg"}}' class="mw-file-element"/></a><figcaption>This is a caption</figcaption></figure>
!! end
!! test
3. Inline image with individual attributes from templates
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|{{1x|50px}}]]
!! html/php
<p><span typeof="mw:File"><a href="/wiki/File:Foobar.jpg" class="mw-file-description"><img src="http://example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg" decoding="async" width="50" height="6" class="mw-file-element" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/75px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/100px-Foobar.jpg 2x" /></a></span>
</p>
!! html/parsoid
<p><span typeof="mw:File mw:ExpandedAttrs" about="#mwt2" data-parsoid='{"optList":[{"ck":"width","ak":"{{1x|50px}}"}]}' data-mw='{"attribs":[["width",{"html":"<span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid='{\"pi\":[[{\"k\":\"1\"}]]}' data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"1x\",\"href\":\"./Template:1x\"},\"params\":{\"1\":{\"wt\":\"50px\"}},\"i\":0}}]}'>50px</span>"}]]}'><a href="./File:Foobar.jpg" class="mw-file-description"><img resource="./File:Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="6" width="50" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/75px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/100px-Foobar.jpg 2x" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"6","width":"50"},"sa":{"resource":"File:Foobar.jpg"}}' class="mw-file-element"/></a></span></p>
!! end
## Parsoid does not provide editing support for images where templates produce multiple image attributes.
## To signal this, we add a 'mw:Placeholder' type to such images. This could change in the future.
!! test
Image with multiple attributes from the same template
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|{{image_attribs}}]]
!! html/php
<figure class="mw-default-size mw-halign-right" typeof="mw:File"><a href="/wiki/File:Foobar.jpg" class="mw-file-description" title="Caption text"><img alt="Caption text" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" class="mw-file-element" /></a><figcaption>Caption text</figcaption></figure>
!! html/parsoid
<figure class="mw-default-size mw-halign-right" typeof="mw:File mw:Placeholder"><a href="./File:Foobar.jpg" class="mw-file-description" title="Caption text"><img alt="Caption text" resource="./File:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" class="mw-file-element"/></a><figcaption>Caption text</figcaption></figure>
!! end
!! test
Image with link tails
!! options
thumbsize=220
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
123[[File:Foobar.jpg]]456
123[[File:Foobar.jpg|right]]456
123[[File:Foobar.jpg|thumb]]456
!! html/php
<p>123<span class="mw-default-size" typeof="mw:File"><a href="/wiki/File:Foobar.jpg" class="mw-file-description"><img src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" class="mw-file-element" /></a></span>456
</p><p>
123</p><figure class="mw-default-size mw-halign-right" typeof="mw:File"><a href="/wiki/File:Foobar.jpg" class="mw-file-description"><img src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" class="mw-file-element" /></a><figcaption></figcaption></figure><p>456
123</p><figure class="mw-default-size" typeof="mw:File/Thumb"><a href="/wiki/File:Foobar.jpg" class="mw-file-description"><img src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" decoding="async" width="220" height="25" class="mw-file-element" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a><figcaption></figcaption></figure><p>456</p>
!! html/parsoid
<p>123<span class="mw-default-size" typeof="mw:File"><a href="./File:Foobar.jpg" class="mw-file-description"><img resource="./File:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" class="mw-file-element"/></a></span>456</p>
<p>123</p><figure class="mw-default-size mw-halign-right" typeof="mw:File"><a href="./File:Foobar.jpg" class="mw-file-description"><img resource="./File:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" class="mw-file-element"/></a><figcaption></figcaption></figure><p>456
123</p><figure class="mw-default-size" typeof="mw:File/Thumb"><a href="./File:Foobar.jpg" class="mw-file-description"><img resource="./File:Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" class="mw-file-element"/></a><figcaption></figcaption></figure>
<p>456</p>
!! 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
<figure class="mw-default-size mw-halign-right" typeof="mw:File"><a href="/wiki/File:Foobar.jpg" class="mw-file-description" title="Caption3 - accepted"><img alt="Caption3 - accepted" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" class="mw-file-element" /></a><figcaption>Caption3 - accepted</figcaption></figure>
!! html/parsoid
<figure class="mw-default-size mw-halign-right" typeof="mw:File"><a href="./File:Foobar.jpg" class="mw-file-description" title="Caption3 - accepted"><img alt="Caption3 - accepted" resource="./File:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" class="mw-file-element"/></a><figcaption>Caption3 - accepted</figcaption></figure>
!! end
!! test
Image with multiple widths -- use last
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|200px|300px|caption]]
!! html/php
<p><span typeof="mw:File"><a href="/wiki/File:Foobar.jpg" class="mw-file-description" title="caption"><img alt="caption" src="http://example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg" decoding="async" width="300" height="34" class="mw-file-element" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/450px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/600px-Foobar.jpg 2x" /></a></span>
</p>
!! html/parsoid
<p><span typeof="mw:File" data-mw='{"caption":"caption"}'><a href="./File:Foobar.jpg" class="mw-file-description" title="caption"><img alt="caption" resource="./File:Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="34" width="300" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/450px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/600px-Foobar.jpg 2x" class="mw-file-element"/></a></span></p>
!! end
!! test
Image with multiple alignments -- use first (T50664)
!! options
thumbsize=220
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|thumb|left|right|center|caption]]
[[File:Foobar.jpg|middle|text-top|caption]]
!! html/php
<figure class="mw-default-size mw-halign-left" typeof="mw:File/Thumb"><a href="/wiki/File:Foobar.jpg" class="mw-file-description"><img src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" decoding="async" width="220" height="25" class="mw-file-element" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a><figcaption>caption</figcaption></figure>
<p><span class="mw-default-size mw-valign-middle" typeof="mw:File"><a href="/wiki/File:Foobar.jpg" class="mw-file-description" title="caption"><img alt="caption" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" class="mw-file-element" /></a></span>
</p>
!! html/parsoid
<figure class="mw-default-size mw-halign-left" typeof="mw:File/Thumb"><a href="./File:Foobar.jpg" class="mw-file-description"><img resource="./File:Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" class="mw-file-element"/></a><figcaption>caption</figcaption></figure>
<p><span class="mw-default-size mw-valign-middle" typeof="mw:File" data-mw='{"caption":"caption"}'><a href="./File:Foobar.jpg" class="mw-file-description" title="caption"><img alt="caption" resource="./File:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" class="mw-file-element"/></a></span></p>
!! end
!! test
Image with width attribute at different positions
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|200px|right|Caption]]
[[File:Foobar.jpg|right|200px|Caption]]
[[File:Foobar.jpg|right|Caption|200px]]
!! html/php
<figure class="mw-halign-right" typeof="mw:File"><a href="/wiki/File:Foobar.jpg" class="mw-file-description" title="Caption"><img alt="Caption" src="http://example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" decoding="async" width="200" height="23" class="mw-file-element" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/400px-Foobar.jpg 2x" /></a><figcaption>Caption</figcaption></figure>
<figure class="mw-halign-right" typeof="mw:File"><a href="/wiki/File:Foobar.jpg" class="mw-file-description" title="Caption"><img alt="Caption" src="http://example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" decoding="async" width="200" height="23" class="mw-file-element" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/400px-Foobar.jpg 2x" /></a><figcaption>Caption</figcaption></figure>
<figure class="mw-halign-right" typeof="mw:File"><a href="/wiki/File:Foobar.jpg" class="mw-file-description" title="Caption"><img alt="Caption" src="http://example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" decoding="async" width="200" height="23" class="mw-file-element" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/400px-Foobar.jpg 2x" /></a><figcaption>Caption</figcaption></figure>
!! html/parsoid
<figure class="mw-halign-right" typeof="mw:File"><a href="./File:Foobar.jpg" class="mw-file-description" title="Caption"><img alt="Caption" resource="./File:Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="23" width="200" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/400px-Foobar.jpg 2x" class="mw-file-element"/></a><figcaption>Caption</figcaption></figure>
<figure class="mw-halign-right" typeof="mw:File"><a href="./File:Foobar.jpg" class="mw-file-description" title="Caption"><img alt="Caption" resource="./File:Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="23" width="200" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/400px-Foobar.jpg 2x" class="mw-file-element"/></a><figcaption>Caption</figcaption></figure>
<figure class="mw-halign-right" typeof="mw:File"><a href="./File:Foobar.jpg" class="mw-file-description" title="Caption"><img alt="Caption" resource="./File:Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="23" width="200" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/400px-Foobar.jpg 2x" class="mw-file-element"/></a><figcaption>Caption</figcaption></figure>
!! end
# a sad bit of backward-compatibility
!! test
Image with size specified with pxpx (T15500, T53628)
!! options
parsoid=wt2html,wt2wt,html2html
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|20pxpx]]
[[File:Foobar.jpg|200x20pxpx]]
!! html/php
<p><span typeof="mw:File"><a href="/wiki/File:Foobar.jpg" class="mw-file-description"><img src="http://example.com/images/thumb/3/3a/Foobar.jpg/20px-Foobar.jpg" decoding="async" width="20" height="2" class="mw-file-element" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/30px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/40px-Foobar.jpg 2x" /></a></span>
<span typeof="mw:File"><a href="/wiki/File:Foobar.jpg" class="mw-file-description"><img src="http://example.com/images/thumb/3/3a/Foobar.jpg/177px-Foobar.jpg" decoding="async" width="177" height="20" class="mw-file-element" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/265px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/353px-Foobar.jpg 2x" /></a></span>
</p>
!! html/parsoid
<p><span typeof="mw:File"><a href="./File:Foobar.jpg" class="mw-file-description"><img resource="./File:Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/20px-Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="2" width="20" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/30px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/40px-Foobar.jpg 2x" class="mw-file-element"/></a></span> <span typeof="mw:File"><a href="./File:Foobar.jpg" class="mw-file-description"><img resource="./File:Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/177px-Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="20" width="177" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/265px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/353px-Foobar.jpg 2x" class="mw-file-element"/></a></span></p>
!! end
!! test
Image with link parameter, wiki target
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|link=Main Page]]
!! html/php
<p><span class="mw-default-size" typeof="mw:File"><a href="/wiki/Main_Page" title="Main Page"><img src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" class="mw-file-element" /></a></span>
</p>
!! html/parsoid
<p><span class="mw-default-size" typeof="mw:File"><a href="./Main_Page" title="Main Page"><img resource="./File:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" class="mw-file-element"/></a></span></p>
!! end
!! test
File with link to page section
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[Main Page#section]]
[[File:Foobar.jpg|link=Main Page#section]]
!! html/php
<p><a href="/wiki/Main_Page#section" title="Main Page">Main Page#section</a>
<span class="mw-default-size" typeof="mw:File"><a href="/wiki/Main_Page#section" title="Main Page"><img src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" class="mw-file-element" /></a></span>
</p>
!! html/parsoid
<p><a rel="mw:WikiLink" href="./Main_Page#section" title="Main Page">Main Page#section</a>
<span class="mw-default-size" typeof="mw:File"><a href="./Main_Page#section" title="Main Page"><img resource="./File:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" class="mw-file-element"/></a></span></p>
!! end
# parsoid T51293 (part 1)
!! test
Image with link parameter, URL target
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|link=http://example.com/]]
!! html/php
<p><span class="mw-default-size" typeof="mw:File"><a href="http://example.com/" rel="nofollow"><img src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" class="mw-file-element" /></a></span>
</p>
!! html/parsoid
<p><span class="mw-default-size" typeof="mw:File"><a href="http://example.com/"><img resource="./File:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" class="mw-file-element"/></a></span></p>
!! end
# parsoid T51293 (part 2)
!! test
Image with link parameter, protocol-less URL target
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|link=//example.com/]]
!! html/php
<p><span class="mw-default-size" typeof="mw:File"><a href="//example.com/" rel="nofollow"><img src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" class="mw-file-element" /></a></span>
</p>
!! html/parsoid
<p><span class="mw-default-size" typeof="mw:File"><a href="//example.com/"><img resource="./File:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" class="mw-file-element"/></a></span></p>
!! end
!! test
Escaping non-block captions (T107435)
!! options
parsoid={
"modes": ["wt2wt"],
"changes": [
["[typeof~='mw:File']", "attr", "data-mw", "{\"caption\": \"|\"}"]
]
}
!! wikitext
[[Image:Foobar.jpg|alt=123|caption]]
!! wikitext/edited
[[Image:Foobar.jpg|alt=123|<nowiki>|</nowiki>]]
!! end
!! test
Image with link parameter, wgExternalLinkTarget
!! wikitext
[[File:Foobar.jpg|link=http://example.com/]]
!! config
wgExternalLinkTarget="foobar"
wgParserEnableLegacyMediaDOM=false
!! html/php
<p><span class="mw-default-size" typeof="mw:File"><a href="http://example.com/" target="foobar" rel="nofollow noreferrer noopener"><img src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" class="mw-file-element" /></a></span>
</p>
!! html/parsoid
<p><span class="mw-default-size" typeof="mw:File"><a href="http://example.com/" rel="nofollow noreferrer noopener" target="foobar"><img resource="./File:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" class="mw-file-element"/></a></span></p>
!! end
!! test
Thumb with link parameter, wgExternalLinkTarget
!! wikitext
[[File:Foobar.jpg|link=http://example.com/|thumb]]
!! config
wgExternalLinkTarget="foobar"
wgParserEnableLegacyMediaDOM=false
!! html/php
<figure class="mw-default-size" typeof="mw:File/Thumb"><a href="http://example.com/" target="foobar" rel="nofollow noreferrer noopener"><img resource="/wiki/File:Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" decoding="async" width="180" height="20" class="mw-file-element" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a><figcaption></figcaption></figure>
!! html/parsoid
<figure class="mw-default-size" typeof="mw:File/Thumb"><a href="http://example.com/" rel="nofollow noreferrer noopener" target="foobar"><img resource="./File:Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="20" width="180" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" class="mw-file-element"/></a><figcaption></figcaption></figure>
!! end
!! test
Image with link parameter, wgNoFollowLinks set to false
!! wikitext
[[File:Foobar.jpg|link=http://example.com/]]
!! config
wgNoFollowLinks=false
wgParserEnableLegacyMediaDOM=false
!! html/php
<p><span class="mw-default-size" typeof="mw:File"><a href="http://example.com/"><img src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" class="mw-file-element" /></a></span>
</p>
!! html/parsoid
<p><span class="mw-default-size" typeof="mw:File"><a href="http://example.com/"><img resource="./File:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" class="mw-file-element"/></a></span></p>
!! end
!! test
Image with link parameter, wgNoFollowDomainExceptions
!! wikitext
[[File:Foobar.jpg|link=http://example.com/]]
!! config
wgNoFollowDomainExceptions="example.com"
wgParserEnableLegacyMediaDOM=false
!! html/php
<p><span class="mw-default-size" typeof="mw:File"><a href="http://example.com/"><img src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" class="mw-file-element" /></a></span>
</p>
!! html/parsoid
<p><span class="mw-default-size" typeof="mw:File"><a href="http://example.com/"><img resource="./File:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" class="mw-file-element"/></a></span></p>
!! end
!! test
Image with link parameter, wgExternalLinkTarget, unnamed parameter
!! wikitext
[[File:Foobar.jpg|link=http://example.com/|Title]]
!! config
wgExternalLinkTarget="foobar"
wgParserEnableLegacyMediaDOM=false
!! html/php
<p><span class="mw-default-size" typeof="mw:File"><a href="http://example.com/" title="Title" target="foobar" rel="nofollow noreferrer noopener"><img alt="Title" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" class="mw-file-element" /></a></span>
</p>
!! html/parsoid
<p><span class="mw-default-size" typeof="mw:File" data-mw='{"caption":"Title"}'><a href="http://example.com/" rel="nofollow noreferrer noopener" target="foobar" title="Title"><img alt="Title" resource="./File:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" class="mw-file-element"/></a></span></p>
!! end
!! test
Image with empty link parameter
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|link=]]
!! html/php
<p><span class="mw-default-size" typeof="mw:File"><span><img src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" class="mw-file-element" /></span></span>
</p>
!! html/parsoid
<p><span class="mw-default-size" typeof="mw:File"><span><img resource="./File:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" class="mw-file-element"/></span></span></p>
!! end
!! test
Image with link parameter (wiki target) and unnamed parameter
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|link=Main_Page|Title]]
!! html/php
<p><span class="mw-default-size" typeof="mw:File"><a href="/wiki/Main_Page" title="Title"><img alt="Title" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" class="mw-file-element" /></a></span>
</p>
!! html/parsoid
<p><span class="mw-default-size" typeof="mw:File" data-mw='{"caption":"Title"}'><a href="./Main_Page" title="Title"><img alt="Title" resource="./File:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" class="mw-file-element"/></a></span></p>
!! end
!! test
Image with link parameter (URL target) and unnamed parameter
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|link=http://example.com/|Title]]
!! html/php
<p><span class="mw-default-size" typeof="mw:File"><a href="http://example.com/" title="Title" rel="nofollow"><img alt="Title" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" class="mw-file-element" /></a></span>
</p>
!! html/parsoid
<p><span class="mw-default-size" typeof="mw:File" data-mw='{"caption":"Title"}'><a href="http://example.com/" title="Title"><img alt="Title" resource="./File:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" class="mw-file-element"/></a></span></p>
!! end
!! test
Thumbnail image with link parameter
!! options
thumbsize=220
parsoid=wt2html,wt2wt,html2html
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|thumb|link=http://example.com/|Title]]
!! html/php
<figure class="mw-default-size" typeof="mw:File/Thumb"><a href="http://example.com/" rel="nofollow"><img resource="/wiki/File:Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" decoding="async" width="220" height="25" class="mw-file-element" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a><figcaption>Title</figcaption></figure>
!! html/parsoid
<figure class="mw-default-size" typeof="mw:File/Thumb"><a href="http://example.com/"><img resource="./File:Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" class="mw-file-element"/></a><figcaption>Title</figcaption></figure>
!! end
!! test
Manually-specified thumbnail image
!! options
thumbsize=220
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|thumbnail=Thumb.png|Title]]
!! html/php
<figure typeof="mw:File/Thumb"><a href="/wiki/File:Foobar.jpg" title="File:Foobar.jpg"><img resource="/wiki/File:Foobar.jpg" src="http://example.com/images/e/ea/Thumb.png" decoding="async" width="135" height="135" class="mw-file-element" /></a><figcaption>Title</figcaption></figure>
!! html/parsoid
<figure typeof="mw:File/Thumb" about="#mwt1" data-mw='{"attribs":[["manualthumb",{"txt":"Thumb.png"}]]}'><a href="./File:Foobar.jpg" class="mw-file-description"><img resource="./File:Foobar.jpg" src="http://example.com/images/e/ea/Thumb.png" decoding="async" data-file-width="135" data-file-height="135" data-file-type="bitmap" height="135" width="135" class="mw-file-element"/></a><figcaption>Title</figcaption></figure>
!! end
!! test
Manually-specified thumbnail image (backwards compat)
!! options
thumbsize=220
parsoid=html2wt
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|thumbnail=Thumb.png|Title]]
!! html/php
<figure typeof="mw:File/Thumb"><a href="/wiki/File:Foobar.jpg" title="File:Foobar.jpg"><img resource="/wiki/File:Foobar.jpg" src="http://example.com/images/e/ea/Thumb.png" decoding="async" width="135" height="135" class="mw-file-element" /></a><figcaption>Title</figcaption></figure>
!! html/parsoid
<figure class="mw-default-size" typeof="mw:File/Thumb" data-mw='{"thumb":"Thumb.png"}'><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="http://example.com/images/e/ea/Thumb.png" decoding="async" data-file-width="135" data-file-height="135" data-file-type="bitmap" height="135" width="135" class="mw-file-element"/></a><figcaption>Title</figcaption></figure>
!! end
!! test
Manually-specified thumbnail image with explicit link to wiki page
!! options
thumbsize=220
parsoid=wt2html,wt2wt,html2html
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|Title]]
!! html/php
<figure typeof="mw:File/Thumb"><a href="/wiki/Main_Page" title="Main Page"><img resource="/wiki/File:Foobar.jpg" src="http://example.com/images/e/ea/Thumb.png" decoding="async" width="135" height="135" class="mw-file-element" /></a><figcaption>Title</figcaption></figure>
!! html/parsoid
<figure typeof="mw:File/Thumb" data-mw='{"attribs":[["manualthumb",{"txt":"Thumb.png"}]]}'><a href="./Main_Page" title="Main Page"><img resource="./File:Foobar.jpg" src="http://example.com/images/e/ea/Thumb.png" decoding="async" data-file-width="135" data-file-height="135" data-file-type="bitmap" height="135" width="135" class="mw-file-element"/></a><figcaption>Title</figcaption></figure>
!! end
!! test
Manually-specified thumbnail image with explicit link to url
!! options
thumbsize=220
parsoid=wt2html,wt2wt,html2html
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|thumb=Thumb.png|link=http://example.com|Title]]
!! html/php
<figure typeof="mw:File/Thumb"><a href="http://example.com" rel="nofollow"><img resource="/wiki/File:Foobar.jpg" src="http://example.com/images/e/ea/Thumb.png" decoding="async" width="135" height="135" class="mw-file-element" /></a><figcaption>Title</figcaption></figure>
!! html/parsoid
<figure typeof="mw:File/Thumb" data-mw='{"attribs":[["manualthumb",{"txt":"Thumb.png"}]]}'><a href="http://example.com"><img resource="./File:Foobar.jpg" src="http://example.com/images/e/ea/Thumb.png" decoding="async" data-file-width="135" data-file-height="135" data-file-type="bitmap" height="135" width="135" class="mw-file-element"/></a><figcaption>Title</figcaption></figure>
!! end
!! test
Manually-specified thumbnail image with explicit no link
!! options
thumbsize=220
parsoid=wt2html,wt2wt,html2html
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|thumb=Thumb.png|link=|Title]]
!! html/php
<figure typeof="mw:File/Thumb"><span><img resource="/wiki/File:Foobar.jpg" src="http://example.com/images/e/ea/Thumb.png" decoding="async" width="135" height="135" class="mw-file-element" /></span><figcaption>Title</figcaption></figure>
!! html/parsoid
<figure typeof="mw:File/Thumb" data-mw='{"attribs":[["manualthumb",{"txt":"Thumb.png"}]]}'><span><img resource="./File:Foobar.jpg" src="http://example.com/images/e/ea/Thumb.png" decoding="async" data-file-width="135" data-file-height="135" data-file-type="bitmap" height="135" width="135" class="mw-file-element"/></span><figcaption>Title</figcaption></figure>
!! end
!! test
Manually-specified thumbnail image with explicit link and alt text
!! options
thumbsize=220
parsoid=wt2html,wt2wt,html2html
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|alt=alttext|Title]]
!! html/php
<figure typeof="mw:File/Thumb"><a href="/wiki/Main_Page" title="Main Page"><img alt="alttext" resource="/wiki/File:Foobar.jpg" src="http://example.com/images/e/ea/Thumb.png" decoding="async" width="135" height="135" class="mw-file-element" /></a><figcaption>Title</figcaption></figure>
!! html/parsoid
<figure typeof="mw:File/Thumb" data-mw='{"attribs":[["manualthumb",{"txt":"Thumb.png"}]]}'><a href="./Main_Page" title="Main Page"><img alt="alttext" resource="./File:Foobar.jpg" src="http://example.com/images/e/ea/Thumb.png" decoding="async" data-file-width="135" data-file-height="135" data-file-type="bitmap" height="135" width="135" class="mw-file-element"/></a><figcaption>Title</figcaption></figure>
!! end
!! test
Image with frame and link
!! options
parsoid=wt2html,wt2wt,html2html
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|frame|left|This is a test image [[Main Page]]]]
!! html/php
<figure class="mw-halign-left" typeof="mw:File/Frame"><a href="/wiki/File:Foobar.jpg" class="mw-file-description"><img src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" class="mw-file-element" /></a><figcaption>This is a test image <a href="/wiki/Main_Page" title="Main Page">Main Page</a></figcaption></figure>
!! html/parsoid
<figure class="mw-halign-left" typeof="mw:File/Frame"><a href="./File:Foobar.jpg" class="mw-file-description"><img resource="./File:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" class="mw-file-element"/></a><figcaption>This is a test image <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></figcaption></figure>
!! end
!! test
Image with frame and link and explicit alt
!! options
parsoid=wt2html,wt2wt,html2html
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[Image:Foobar.jpg|frame|left|This is a test image [[Main Page]]|alt=Altitude]]
!! html/php
<figure class="mw-halign-left" typeof="mw:File/Frame"><a href="/wiki/File:Foobar.jpg" class="mw-file-description"><img alt="Altitude" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" class="mw-file-element" /></a><figcaption>This is a test image <a href="/wiki/Main_Page" title="Main Page">Main Page</a></figcaption></figure>
!! html/parsoid
<figure class="mw-halign-left" typeof="mw:File/Frame"><a href="./File:Foobar.jpg" class="mw-file-description"><img alt="Altitude" resource="./File:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" class="mw-file-element"/></a><figcaption>This is a test image <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></figcaption></figure>
!! end
!! test
Image with wiki markup in implicit alt
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[Image:Foobar.jpg|testing '''bold''' in alt]]
[[Image:Foobar.jpg|alt=testing '''bold''' in alt]]
!! html/php
<p><span class="mw-default-size" typeof="mw:File"><a href="/wiki/File:Foobar.jpg" class="mw-file-description" title="testing bold in alt"><img alt="testing bold in alt" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" class="mw-file-element" /></a></span>
</p><p><span class="mw-default-size" typeof="mw:File"><a href="/wiki/File:Foobar.jpg" class="mw-file-description"><img alt="testing bold in alt" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" class="mw-file-element" /></a></span>
</p>
!! html/parsoid
<p><span class="mw-default-size" typeof="mw:File" data-parsoid='{"optList":[{"ck":"caption","ak":"testing '''bold''' in alt"}]}' data-mw='{"caption":"testing <b data-parsoid='{\"dsr\":[27,37,3,3]}'>bold</b> in alt"}'><a href="./File:Foobar.jpg" class="mw-file-description" title="testing bold in alt"><img alt="testing bold in alt" resource="./File:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"Image:Foobar.jpg"}}' class="mw-file-element"/></a></span></p>
<p><span class="mw-default-size" typeof="mw:File mw:ExpandedAttrs" about="#mwt1" data-parsoid='{"optList":[{"ck":"alt","ak":"alt=testing '''bold''' in alt"}]}' data-mw='{"attribs":[["alt",{"html":"alt=testing <b data-parsoid='{\"dsr\":[79,89,3,3]}'>bold</b> in alt","txt":"testing bold in alt"}]]}'><a href="./File:Foobar.jpg" class="mw-file-description"><img alt="testing bold in alt" resource="./File:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"Image:Foobar.jpg"}}' class="mw-file-element"/></a></span></p>
!! end
!! test
Alt image option should handle most kinds of wikitext without barfing
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[Image:Foobar.jpg|thumb|This is the image caption|alt=This is a [[link]] and a {{1x|''bold template''}}.]]
!! html/php
<figure class="mw-default-size" typeof="mw:File/Thumb"><a href="/wiki/File:Foobar.jpg" class="mw-file-description"><img alt="This is a link and a bold template." src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" decoding="async" width="180" height="20" class="mw-file-element" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a><figcaption>This is the image caption</figcaption></figure>
!! html/parsoid
<figure class="mw-default-size" typeof="mw:File/Thumb mw:ExpandedAttrs" about="#mwt2" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"caption","ak":"This is the image caption"},{"ck":"alt","ak":"alt=This is a [[link]] and a {{1x|''bold template''}}."}]}' data-mw='{"attribs":[["alt",{"html":"alt=This is a <a rel=\"mw:WikiLink\" href=\"./Link\" title=\"Link\" data-parsoid='{\"stx\":\"simple\",\"a\":{\"href\":\"./Link\"},\"sa\":{\"href\":\"link\"},\"dsr\":[65,73,2,2]}'>link</a> and a <i about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid='{\"dsr\":[80,104,null,null],\"pi\":[[{\"k\":\"1\"}]]}' data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"1x\",\"href\":\"./Template:1x\"},\"params\":{\"1\":{\"wt\":\"&apos;&apos;bold template&apos;&apos;\"}},\"i\":0}}]}'>bold template</i>.","txt":"This is a link and a bold template."}]]}'><a href="./File:Foobar.jpg" class="mw-file-description"><img alt="This is a link and a bold template." resource="./File:Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="20" width="180" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"20","width":"180"},"sa":{"resource":"Image:Foobar.jpg"}}' class="mw-file-element"/></a><figcaption>This is the image caption</figcaption></figure>
!! end
!! test
Ampersand in alt attribute (T206940)
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|alt=&amp;]]
<!-- consistency with gallery extension -->
<gallery>
File:Foobar.jpg|alt=&amp;
</gallery>
!! html/php
<p><span class="mw-default-size" typeof="mw:File"><a href="/wiki/File:Foobar.jpg" class="mw-file-description"><img alt="&amp;" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" class="mw-file-element" /></a></span>
</p>
<ul class="gallery mw-gallery-traditional">
<li class="gallerybox" style="width: 155px">
<div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:File"><a href="/wiki/File:Foobar.jpg" class="mw-file-description"><img alt="&amp;" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" decoding="async" width="120" height="14" class="mw-file-element" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></span></div>
<div class="gallerytext"></div>
</li>
</ul>
!! html/parsoid
<p><span class="mw-default-size" typeof="mw:File mw:ExpandedAttrs" about="#mwt1" data-mw='{"attribs":[["alt",{"html":"alt=<span typeof=\"mw:Entity\" data-parsoid='{\"src\":\"&amp;amp;\",\"srcContent\":\"&amp;\",\"dsr\":[22,27,null,null]}'>&amp;</span>amp;","txt":"&amp;"}]]}'><a href="./File:Foobar.jpg" class="mw-file-description"><img alt="&amp;" resource="./File:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" class="mw-file-element"/></a></span></p>
<!-- consistency with gallery extension -->
<ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt5" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
<li class="gallerybox" style="width: 155px;">
<div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:File mw:ExpandedAttrs" data-mw='{"attribs":[["alt",{"html":"alt=<span typeof=\"mw:Entity\" data-parsoid='{\"src\":\"&amp;amp;\",\"srcContent\":\"&amp;\",\"dsr\":[109,114,null,null]}'>&amp;</span>amp;","txt":"&amp;"}]]}'><a href="./File:Foobar.jpg" class="mw-file-description"><img alt="&amp;" resource="./File:Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" class="mw-file-element"/></a></span></div>
<div class="gallerytext"></div>
</li>
</ul>
!! end
## FIXME: The inconsistency in the gallery extension on the php side is T49646
# Parsoid test is only wt2html because it inserts <nowiki> around the
# alt text when serializing (which is fine).
!! test
Link with encoded pipe in alt option
!! config
wgParserEnableLegacyMediaDOM=false
!! options
parsoid=wt2html
!! wikitext
[[File:Foobar.jpg|alt=http://testing.123?4=5|6|caption]]
[[File:Foobar.jpg|alt=http://testing.123?4=5|6|caption]]
<!-- consistency with gallery extension -->
<gallery>
File:Foobar.jpg|alt=http://testing.123?4=5|6|caption
File:Foobar.jpg|alt=http://testing.123?4=5|6|caption
</gallery>
!! html/php
<p><span class="mw-default-size" typeof="mw:File"><a href="/wiki/File:Foobar.jpg" class="mw-file-description" title="caption"><img alt="http://testing.123?4=5|6" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" class="mw-file-element" /></a></span>
</p><p><span class="mw-default-size" typeof="mw:File"><a href="/wiki/File:Foobar.jpg" class="mw-file-description" title="caption"><img alt="http://testing.123?4=5|6" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" class="mw-file-element" /></a></span>
</p>
<ul class="gallery mw-gallery-traditional">
<li class="gallerybox" style="width: 155px">
<div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:File"><a href="/wiki/File:Foobar.jpg" class="mw-file-description"><img alt="http://testing.123?4=5%7C6%7Ccaption" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" decoding="async" width="120" height="14" class="mw-file-element" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></span></div>
<div class="gallerytext"></div>
</li>
<li class="gallerybox" style="width: 155px">
<div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:File"><a href="/wiki/File:Foobar.jpg" class="mw-file-description"><img alt="http://testing.123?4=5%7C6%7Ccaption" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" decoding="async" width="120" height="14" class="mw-file-element" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></span></div>
<div class="gallerytext"></div>
</li>
</ul>
!! html/parsoid
<p><span class="mw-default-size" typeof="mw:File mw:ExpandedAttrs" about="#mwt1" data-parsoid='{"optList":[{"ck":"alt","ak":"alt=http://testing.123?4=5&#x7C;6"},{"ck":"caption","ak":"caption"}]}' data-mw='{"attribs":[["alt",{"html":"alt=<a rel=\"mw:ExtLink\" href=\"http://testing.123?4=5%7C6\" data-parsoid='{\"stx\":\"url\",\"a\":{\"href\":\"http://testing.123?4=5%7C6\"},\"sa\":{\"href\":\"http://testing.123?4=5&amp;#x7C;6\"},\"dsr\":[22,51,0,0]}'>http://testing.123?4=5%7C6</a>","txt":"http://testing.123?4=5|6"}]],"caption":"caption"}'><a href="./File:Foobar.jpg" class="mw-file-description" title="caption"><img alt="http://testing.123?4=5|6" resource="./File:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" class="mw-file-element"/></a></span></p>
<p><span class="mw-default-size" typeof="mw:File mw:ExpandedAttrs" about="#mwt1" data-parsoid='{"optList":[{"ck":"alt","ak":"alt=http://testing.123?4=5&vert;6"},{"ck":"caption","ak":"caption"}]}' data-mw='{"attribs":[["alt",{"html":"alt=<a rel=\"mw:ExtLink\" href=\"http://testing.123?4=5%7C6\" data-parsoid='{\"stx\":\"url\",\"a\":{\"href\":\"http://testing.123?4=5%7C6\"},\"sa\":{\"href\":\"http://testing.123?4=5&amp;vert;6\"},\"dsr\":[22,51,0,0]}'>http://testing.123?4=5%7C6</a>","txt":"http://testing.123?4=5|6"}]],"caption":"caption"}'><a href="./File:Foobar.jpg" class="mw-file-description" title="caption"><img alt="http://testing.123?4=5|6" resource="./File:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" class="mw-file-element"/></a></span></p>
<!-- consistency with gallery extension -->
<ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt5" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:File mw:ExpandedAttrs" data-parsoid='{"optList":[{"ck":"width","ak":"120x120px"},{"ck":"none","ak":"none"},{"ck":"alt","ak":"alt=http://testing.123?4=5&#x7C;6"},{"ck":"caption","ak":"caption"}]}' data-mw='{"attribs":[["alt",{"html":"alt=<a rel=\"mw:ExtLink\" href=\"http://testing.123?4=5%7C6\" data-parsoid='{\"stx\":\"url\",\"a\":{\"href\":\"http://testing.123?4=5%7C6\"},\"sa\":{\"href\":\"http://testing.123?4=5&amp;#x7C;6\"},\"dsr\":[200,229,0,0]}'>http://testing.123?4=5%7C6</a>","txt":"http://testing.123?4=5|6"}]]}'><a href="./File:Foobar.jpg" class="mw-file-description" title="caption"><img alt="http://testing.123?4=5|6" resource="./File:Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" class="mw-file-element"/></a></span></div><div class="gallerytext">caption</div></li>
<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:File mw:ExpandedAttrs" data-parsoid='{"optList":[{"ck":"width","ak":"120x120px"},{"ck":"none","ak":"none"},{"ck":"alt","ak":"alt=http://testing.123?4=5&vert;6"},{"ck":"caption","ak":"caption"}]}' data-mw='{"attribs":[["alt",{"html":"alt=<a rel=\"mw:ExtLink\" href=\"http://testing.123?4=5%7C6\" data-parsoid='{\"stx\":\"url\",\"a\":{\"href\":\"http://testing.123?4=5%7C6\"},\"sa\":{\"href\":\"http://testing.123?4=5&amp;vert;6\"},\"dsr\":[137,166,0,0]}'>http://testing.123?4=5%7C6</a>","txt":"http://testing.123?4=5|6"}]]}'><a href="./File:Foobar.jpg" class="mw-file-description" title="caption"><img alt="http://testing.123?4=5|6" resource="./File:Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" class="mw-file-element"/></a></span></div><div class="gallerytext">caption</div>
</li>
</ul>
!! end
!! test
Italics markup in alt attribute (T206940)
!! options
parsoid=wt2html,html2html
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|alt=''x''|caption]]
<!-- consistency with gallery extension -->
<gallery>
File:Foobar.jpg|alt=''x''|caption
</gallery>
!! html/php
<p><span class="mw-default-size" typeof="mw:File"><a href="/wiki/File:Foobar.jpg" class="mw-file-description" title="caption"><img alt="x" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" class="mw-file-element" /></a></span>
</p>
<ul class="gallery mw-gallery-traditional">
<li class="gallerybox" style="width: 155px">
<div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:File"><a href="/wiki/File:Foobar.jpg" class="mw-file-description" title="caption"><img alt="x" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" decoding="async" width="120" height="14" class="mw-file-element" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></span></div>
<div class="gallerytext">caption</div>
</li>
</ul>
!! html/parsoid
<p><span class="mw-default-size" typeof="mw:File mw:ExpandedAttrs" about="#mwt1" data-parsoid='{"optList":[{"ck":"alt","ak":"alt=''x''"},{"ck":"caption","ak":"caption"}]}' data-mw='{"attribs":[["alt",{"html":"alt=<i data-parsoid='{\"dsr\":[22,27,2,2]}'>x</i>","txt":"x"}]],"caption":"caption"}'><a href="./File:Foobar.jpg" class="mw-file-description" title="caption"><img alt="x" resource="./File:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" class="mw-file-element"/></a></span></p>
<!-- consistency with gallery extension -->
<ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt5" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:File mw:ExpandedAttrs" data-mw='{"attribs":[["alt",{"html":"alt=<i data-parsoid='{\"dsr\":[113,118,2,2]}'>x</i>","txt":"x"}]]}'><a href="./File:Foobar.jpg" class="mw-file-description" title="caption"><img alt="x" resource="./File:Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" class="mw-file-element"/></a></span></div>
<div class="gallerytext">caption</div>
</li>
</ul>
!! end
!! test
Nowiki markup in alt attribute (edited html, no data-parsoid) (T206940)
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|alt=<nowiki>''x''</nowiki>|caption]]
<!-- consistency with gallery extension -->
<gallery>
File:Foobar.jpg|alt=<nowiki>''x''</nowiki>|caption
</gallery>
!! html/php
<p><span class="mw-default-size" typeof="mw:File"><a href="/wiki/File:Foobar.jpg" class="mw-file-description" title="caption"><img alt="''x''" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" class="mw-file-element" /></a></span>
</p>
<ul class="gallery mw-gallery-traditional">
<li class="gallerybox" style="width: 155px">
<div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:File"><a href="/wiki/File:Foobar.jpg" class="mw-file-description" title="caption"><img alt="''x''" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" decoding="async" width="120" height="14" class="mw-file-element" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></span></div>
<div class="gallerytext">caption</div>
</li>
</ul>
!! html/parsoid
<p><span class="mw-default-size" typeof="mw:File mw:ExpandedAttrs" about="#mwt3" data-mw='{"attribs":[["alt",{"html":"alt=<span typeof=\"mw:Nowiki\" data-parsoid='{\"dsr\":[22,44,8,9]}'>''x''</span>","txt":"''x''"}]],"caption":"caption"}'><a href="./File:Foobar.jpg" class="mw-file-description" title="caption"><img alt="''x''" resource="./File:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" class="mw-file-element"/></a></span></p>
<!-- consistency with gallery extension -->
<ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt9" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
<li class="gallerybox" style="width: 155px;">
<div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:File mw:ExpandedAttrs" data-mw='{"attribs":[["alt",{"html":"alt=<span typeof=\"mw:Nowiki\" data-parsoid='{\"dsr\":[130,152,8,9]}'>''x''</span>","txt":"''x''"}]]}'><a href="./File:Foobar.jpg" class="mw-file-description" title="caption"><img alt="''x''" resource="./File:Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" class="mw-file-element"/></a></span></div>
<div class="gallerytext">caption</div></li>
</ul>