Extension:ImageMap

From ModelUSGov Wiki
Jump to navigation Jump to search

<languages/> [[#ref_This extension comes with MediaWiki 1.21 and above. Thus you do not have to download it again. However, you still need to follow the other instructions provided.|^]] [[Category:extensions bundled with MediaWiki 1.21{{#translation:}}]]

Lua error: callParserFunction: function "#translation" was not found.Lua error: callParserFunction: function "#translation" was not found.
MediaWiki extensions manual
OOjs UI icon advanced.svg
Extension:ImageMap
Release status: stable[[Category:stable extensions{{#translation:}}]]
Implementation Lua error: callParserFunction: function "#translation" was not found.
Description <translate> Allows clickable HTML image maps</translate>
Author(s) Tim Starlingtalk
Latest version Lua error: callParserFunction: function "#translation" was not found.
MediaWiki 1.23+
PHP 5.4+
Database changes Lua error: callParserFunction: function "#translation" was not found.
Composer mediawiki/image-map [[Category:Extensions supporting Composer{{#translation:}}]]
License Lua error: callParserFunction: function "#translation" was not found.
Download [[Category:Extensions in Wikimedia version control{{#translation:}}]]
log
Example Children's encyclopedia
Lua error: callParserFunction: function "#translation" was not found.

Lua error: callParserFunction: function "#translation" was not found.

Translate the Extension:ImageMap extension if it is available at translatewiki.net

Check usage and version matrix.

Issues Open tasks · Report a bug
[[Category:All extensions{{#translation:}}]] Lua error: callParserFunction: function "#translation" was not found.

<translate> The ImageMap extension allows clickable image maps.</translate> <translate> An image map is a list of coordinates in a specific image, which hyperlinks areas of the image to multiple destinations (in contrast to a normal image link, in which the entire area of the image links to a single destination).</translate> <translate> For example, a map of the world may have each country hyperlinked to further information about that country.</translate> <translate> The intention of an image map is to provide an easy way of linking various parts of an image without dividing the image into separate image files. </translate>

<translate>

Examples[edit | edit source]

Simple example without caption[edit | edit source]

</translate>

<imagemap>
File:Example2.png|150px|alt=Alt text
default [[Main Page|Go to main page]]
</imagemap>

<imagemap> Image:Example2.png|150px|alt=Alt text default Go to main page </imagemap>

The above example always links to the Main Page, no matter where you click on it. To find out more about the image, click on the blue "i" icon . An alternative way to create such a linked image, without using this extension would be with [[Image:Example2.png|150px|alt=Alt text|title=Go to main page|link=Main Page]]

<translate>

Complex example with caption[edit | edit source]

</translate>

<imagemap>
File:JoshuaReynoldsParty.jpg|thumb|center|400px|alt=Dining room with nine men seated around a table. The dinner has been finished, and a large man at the head talks and gesticulates while the others eagerly listen. The men wear wigs and clothing of late 18th century Britain, and the furniture, hangings, and chandelier are of similar vintage. A liveried servant is entering with a tray bearing two high-shouldered decanters of wine.|Image map example. Clicking on a person in the picture causes the browser to load the appropriate article.

poly 133 343 124 287 159 224 189 228 195 291 222 311 209 343 209 354 243 362 292 466 250 463 [[w:Samuel Johnson|Dr Johnson - Dictionary writer]]
poly 76 224 84 255 43 302 62 400 123 423 121 361 137 344 122 290 111 234 96 225 [[w:James Boswell|Boswell - Biographer]]
poly 190 276 208 240 229 228 247 238 250 258 286 319 282 323 223 323 220 301 200 295 [[w:Joshua Reynolds|Sir Joshua Reynolds - Host]]
poly 308 317 311 270 328 261 316 246 320 228 343 227 357 240 377 274 366 284 352 311 319 324 [[w:David Garrick|David Garrick - actor]]
poly 252 406 313 343 341 343 366 280 383 273 372 251 378 222 409 228 414 280 420 292 390 300 374 360 359 437 306 418 313 391 272 415 [[w:Edmund Burke|Edmund Burke - statesman]]
rect 418 220 452 287 [[w:Pasquale Paoli|Pasqual Paoli - Corsican patriot]]
poly 455 238 484 253 505 303 495 363 501 377 491 443 429 439 423 375 466 352 [[w:Charles Burney|Charles Burney - music historian]]
poly 501 279 546 237 567 239 572 308 560 326 537 316 530 300 502 289 [[w:Thomas Warton|Thomas Warton - poet laureate]]
poly 572 453 591 446 572 373 603 351 562 325 592 288 573 260 573 248 591 243 615 254 637 280 655 334 705 396 656 419 625 382 609 391 613 453 [[w:Oliver Goldsmith|Oliver Goldsmith - writer]]
rect 450 86 584 188 [[w:Joshua Reynolds|prob.The Infant Academy 1782]]
rect 286 87 376 191 [[w:Joshua Reynolds|An unknown painting]]
circle 100 141 20 [[w:Joshua Reynolds|An unknown portrait]]
poly 503 192 511 176 532 176 534 200 553 219 554 234 541 236 525 261 506 261 511 220 515 215 [[w:Francis Barber|servant - poss. Francis Barber]]
rect 12 10 702 500 [[w:The Club (Literary Club)|Use button to enlarge or use hyperlinks]]
</imagemap>

<imagemap> File:JoshuaReynoldsParty.jpg|thumb|center|400px|alt=Dining room with nine men seated around a table. The dinner has been finished, and a large man at the head talks and gesticulates while the others eagerly listen. The men wear wigs and clothing of late 18th century Britain, and the furniture, hangings, and chandelier are of similar vintage. A liveried servant is entering with a tray bearing two high-shouldered decanters of wine.|Image map example. Clicking on a person in the picture causes the browser to load the appropriate article.

poly 133 343 124 287 159 224 189 228 195 291 222 311 209 343 209 354 243 362 292 466 250 463 Dr Johnson - Dictionary writer poly 76 224 84 255 43 302 62 400 123 423 121 361 137 344 122 290 111 234 96 225 Boswell - Biographer poly 190 276 208 240 229 228 247 238 250 258 286 319 282 323 223 323 220 301 200 295 Sir Joshua Reynolds - Host poly 308 317 311 270 328 261 316 246 320 228 343 227 357 240 377 274 366 284 352 311 319 324 David Garrick - actor poly 252 406 313 343 341 343 366 280 383 273 372 251 378 222 409 228 414 280 420 292 390 300 374 360 359 437 306 418 313 391 272 415 Edmund Burke - statesman rect 418 220 452 287 Pasqual Paoli - Corsican patriot poly 455 238 484 253 505 303 495 363 501 377 491 443 429 439 423 375 466 352 Charles Burney - music historian poly 501 279 546 237 567 239 572 308 560 326 537 316 530 300 502 289 Thomas Warton - poet laureate poly 572 453 591 446 572 373 603 351 562 325 592 288 573 260 573 248 591 243 615 254 637 280 655 334 705 396 656 419 625 382 609 391 613 453 Oliver Goldsmith - writer rect 450 86 584 188 prob.The Infant Academy 1782 rect 286 87 376 191 unknown painting circle 100 141 20 An unknown portrait poly 503 192 511 176 532 176 534 200 553 219 554 234 541 236 525 261 506 261 511 220 515 215 servant - poss. Francis Barber rect 12 10 702 500 Use button to enlarge or use hyperlinks </imagemap>

The above example links to many different pages, depending on where you click it. To find out more about the image, click on the double-rectangle icon .

Syntax description[edit | edit source]

The contents of an <imagemap> tag consists of blank lines, comments (starting with #) and logical lines. The first logical line specifies the image to be displayed. This must be in the same format as an ordinary MediaWiki image link (see Images help), except without the enclosing [[ and ]] markup. If the first line specifies a "thumb" or "frame" image, then the first line's caption and any |alt= parameter are treated as the image's caption and alt text in the usual way; otherwise, the first line's |alt= parameter (or, if absent, any caption) specifies the image's alt text. In neither case does the image itself have title text (often used for tooltips); any title text is taken from the regions described in later lines.

Further lines are split into tokens, separated by whitespace. The function of each line is determined by the first token in the line.

A coordinate consists of two tokens. The first token is the horizontal (X) position and the second token is the vertical (Y) position. All coordinates are according to the full-size image, not the visible image. The X and Y tokens should be specified as distance from left edge (horizontal pixel count) and distance from top (vertical pixel count) of the full-size image.

desc
Specifies the location of a blue "i" icon , which links to the image description. Possible values: top-right, bottom-right (default), bottom-left, top-left, none. This parameter is ignored for "thumb" or "frame" images, which instead employ the usual double-rectangle icon .
poly
A polygon. The coordinates of the vertices are given, followed by a link in square brackets.
rect
A rectangle. The parameters are the coordinates of the top-left and bottom-right corners, followed by a title to link to in square brackets.
Example
<imagemap>
Image:PolierMartinWombwellZoffany.jpg|thumb|200px|Colonel Antoine Polier
rect 269 140 344 305 [[Claude Martin]]
rect 124 147 181 298 [[Antoine Polier|Antoine-Louis Polier]]
desc none
</imagemap>
circle
A circle. The first two parameters are the coordinates of the center, the third is the radius. The coordinates are followed by a link in square brackets.
default
This gives the default link, where no other regions are specified.

All coordinates are specified relative to the source image. The image can be scaled using thumbnail syntax, in which case the image map coordinates will be automatically scaled as well.

All links are given in either the form [[Page title]] or [[Page title|description]]. In the latter case, the part after the pipe "|" becomes the title attribute of the link—in most browsers, it will pop up as a tooltip when the user hovers over it; the part after the pipe also becomes the alt text for the link. If no explicit link description is given, the page title is used.

Areas which overlap give precedence to the first link listed.

<translate>

Installation[edit | edit source]

</translate> [[#ref_This extension is bundled with MediaWiki 1.21 and above. Thus you do not have to download it again.|^]] Make sure that uploads and ImageMagick are installed:

$wgEnableUploads = true;
$wgUseImageMagick = true;
$wgImageMagickConvertCommand = "/usr/bin/convert";
  • Download and place the file(s) in a directory called Extension:ImageMap in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php:
    wfLoadExtension( 'Extension:ImageMap' );
    
  • checkY Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

To users running MediaWiki 1.24 or earlier:

The instructions above describe the new way of installing this extension using wfLoadExtension(). If you need to install this extension on these earlier versions (MediaWiki 1.24 and earlier), instead of wfLoadExtension( 'Extension:ImageMap' );, you need to use:

require_once "$IP/extensions/Extension:ImageMap/Extension:ImageMap.php";
Troubleshooting
  1. Check to see if your php DOM is turned on. You may need to install it if it is not.
  2. Check whether ImageMagick is installed, since this extension relies on /usr/bin/convert for the resizing. If it is not present, you could get a page with only XML errors (tip: use the back-button in the browser, because you can still edit the page).

Composer[edit | edit source]

You can also install this extension using built-in Composer support.

composer require mediawiki/image-map @dev

^

<translate>

Usage with templates, magic words, or parser functions.[edit | edit source]

</translate> If you want this extension (as with most tag extensions) to parse template parameters, magic words, or parser functions, you will need to use #tag syntax, such as w:Template:Click did. In this case the vertical bar | must be replaced by a template {{!}}, where the source text of the template is | (except when they appear inside links or parameters).

Example - standard form
<imagemap>
Image:ExamplePlant80.png|60px|ExamplePlant
rect 0 107 294 260 [[Plants/ExamplePlant|ExamplePlant]]
desc none
</imagemap>
Example - with variable {{PAGENAME}}
{{#tag:imagemap|
Image:ExamplePlant80.png{{!}}60px{{!}}ExamplePlant
rect 0 107 294 260 [[{{PAGENAME}}/ExamplePlant|ExamplePlant]]
desc none
}}
Example – Modified to accept an input parameter to control image size

These modifications allow the template size to be adjusted on the edited (target) page and eliminate the need to create duplicate templates of various image sizes.

{{#tag:imagemap|
Image:Examplename.jpg {{!}}{{{1|640px}}}
rect 0 107 294 260
circle 360 114 70
poly 357 216 363 417 211
desc none
}}

Where {{{1|640px}}} is the input parameter “1” and a default image size of 640px. Note: the input parameter requires a text string ending with “px” to function properly. For example, calling a template {{TemplateName|400px}} will display the template at 400 pixels.

To convert the standard (existing) image maps to this optional format:

  • Replace the initial <imagemap> with {{#tag:imagemap|
  • Add {{!}}{{{1|640px}}} after the image name (change the default image size to match the currently existing size).
Note:By changing the default size (640px in this example) to the current image size, none of the existing template calls will have to be modified and will display correctly. Existing template calls can still be modified later by using the input parameter.
  • Replace the final </imagemap> with }} (the trailing braces).

<translate>

See also[edit | edit source]

</translate>

Instructions
Wiki tools
  • ImageMapEdit script - A graphical tool to determine the coordinates that can be installed on any wiki.
Online tools
Similar functionalities
[[Category:Skins used on Wikimedia{{#translation:}}|Extension:ImageMap]]

[[Category:Link extensions{{#translation:}}]] [[Category:Image map extensions{{#translation:}}]]