mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/ImageMap
synced 2024-11-27 15:40:03 +00:00
Make mapName deterministic so it can be tested
Change-Id: Ia906b46fbe8d84ae1482f8efaeb609d08c53bfa8
This commit is contained in:
parent
d7f715635e
commit
b024fddb4d
|
@ -279,9 +279,11 @@ class ImageMap {
|
|||
|
||||
if ( $realmap ) {
|
||||
// Construct the map
|
||||
// Add random number to avoid breaking cached HTML fragments that are
|
||||
// later joined together on the one page (bug 16471)
|
||||
$mapName = "ImageMap_" . ++self::$id . '_' . mt_rand( 0, 0x7fffffff );
|
||||
// Add a hash of the map HTML to avoid breaking cached HTML fragments that are
|
||||
// later joined together on the one page (T18471).
|
||||
// The only way these hashes can clash is if the map is identical, in which
|
||||
// case it wouldn't matter that the "wrong" map was used.
|
||||
$mapName = 'ImageMap_' . substr( md5( $mapHTML ), 0, 16 );
|
||||
$mapHTML = "<map name=\"$mapName\">\n$mapHTML</map>\n";
|
||||
|
||||
// Alter the image tag
|
||||
|
|
|
@ -7,3 +7,15 @@ Image:Foobar.jpg
|
|||
!! result
|
||||
<div class="noresize" style="height: 220px; width: 1941px; "><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220"></img><div style="margin-left: 1921px; margin-top: -20px; text-align: left;"><a href="/wiki/File:Foobar.jpg" title="About this image"><img alt="About this image" src="/extensions/ImageMap/resources/desc-20.png?15600" style="border: none;"></img></a></div></div>
|
||||
!! end
|
||||
|
||||
!! test
|
||||
dummy test
|
||||
!! input
|
||||
<imagemap>
|
||||
File:Foobar.jpg
|
||||
|
||||
poly 10.1 10.9 10 30 -30 15 [[Main Page]]
|
||||
</imagemap>
|
||||
!! result
|
||||
<div class="noresize" style="height: 220px; width: 1941px; "><map name="ImageMap_79ccc6c89d422b0c"><area href="/wiki/Main_Page" shape="poly" coords="10,11,10,30,-30,15" alt="Main Page" title="Main Page"></area></map><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" usemap="#ImageMap_79ccc6c89d422b0c"></img><div style="margin-left: 1921px; margin-top: -20px; text-align: left;"><a href="/wiki/File:Foobar.jpg" title="About this image"><img alt="About this image" src="/extensions/ImageMap/resources/desc-20.png?15600" style="border: none;"></img></a></div></div>
|
||||
!! end
|
||||
|
|
Loading…
Reference in a new issue