mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/ImageMap
synced 2024-11-27 15:40:03 +00:00
Place tooltips if caption isn't visible
Matches Parsoid commit Icbc36b6e9aa1b9f4f27c23f4833c626a725cc154 Bug: T297443 Bug: T108380 Depends-On: I30eba0fb226971ddeda4eb240929e89ef7e5f45f Change-Id: Ic0169d3914c5ce442b063f4bbbb6493966dbb302
This commit is contained in:
parent
04ce450e68
commit
75f95fbc1e
|
@ -370,6 +370,21 @@ class ImageMap {
|
||||||
}
|
}
|
||||||
$wrapper->insertBefore( $imageParent, $anchor );
|
$wrapper->insertBefore( $imageParent, $anchor );
|
||||||
|
|
||||||
|
$typeOf = $wrapper->getAttribute( 'typeof' ) ?? '';
|
||||||
|
preg_match( '#^mw:(?:Image|Video|Audio)(/|$)#', $typeOf, $match );
|
||||||
|
$format = $match[1] ?? '';
|
||||||
|
$hasVisibleMedia = in_array( $format, [ 'Thumb', 'Frame' ], true );
|
||||||
|
|
||||||
|
if ( !$hasVisibleMedia ) {
|
||||||
|
$xpath = new DOMXPath( $wrapper->ownerDocument );
|
||||||
|
$captions = $xpath->query( '//figcaption', $wrapper );
|
||||||
|
$caption = $captions->item( 0 );
|
||||||
|
$captionText = trim( $caption->textContent );
|
||||||
|
if ( $captionText ) {
|
||||||
|
$imageParent->setAttribute( 'title', $captionText );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( isset( $mapNode ) ) {
|
if ( isset( $mapNode ) ) {
|
||||||
$wrapper->insertBefore( $mapNode, $anchor );
|
$wrapper->insertBefore( $mapNode, $anchor );
|
||||||
}
|
}
|
||||||
|
|
|
@ -221,8 +221,8 @@ wgParserEnableLegacyMediaDOM=false
|
||||||
<imagemap>
|
<imagemap>
|
||||||
File:Foobar.jpg|link=|Hi ho
|
File:Foobar.jpg|link=|Hi ho
|
||||||
</imagemap>
|
</imagemap>
|
||||||
!! html/php+disabled
|
!! html/php
|
||||||
<figure class="mw-default-size noresize" typeof="mw:Image"><span><img alt="Hi ho" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" title="Hi ho" width="1941" height="220" /></span><figcaption>Hi ho</figcaption></figure>
|
<figure class="mw-default-size noresize" typeof="mw:Image"><span title="Hi ho"><img alt="Hi ho" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" /></span><figcaption>Hi ho</figcaption></figure>
|
||||||
!! html/parsoid
|
!! html/parsoid
|
||||||
<figure class="mw-default-size noresize" typeof="mw:Image mw:Extension/imagemap" about="#mwt2" data-mw='{"name":"imagemap","attrs":{},"body":{"extsrc":"\nFile:Foobar.jpg|link=|Hi ho\n"}}'><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"/></span><figcaption>Hi ho</figcaption></figure>
|
<figure class="mw-default-size noresize" typeof="mw:Image mw:Extension/imagemap" about="#mwt2" data-mw='{"name":"imagemap","attrs":{},"body":{"extsrc":"\nFile:Foobar.jpg|link=|Hi ho\n"}}'><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"/></span><figcaption>Hi ho</figcaption></figure>
|
||||||
!! end
|
!! end
|
||||||
|
|
Loading…
Reference in a new issue