Extension:ImageMap/zh

ImageMap擴展允許在Wiki中加入可按的HTML圖像地圖（Image Map）. 圖像地圖是一系列對特定圖像的座標組合，而座標圍起來的區域允許以超連結的方式連結到多個頁面. 舉例來說，一張世界地圖可能會記載100多個國家，而使用者可以藉由點擊該國的區域以獲得更多資訊. 圖像地圖擴展提供一個方便的方式來為圖像做細部描述，而不用將圖像分割為多個圖像.

沒有說明文字的簡單例子


上面的例子不管點擊何處皆會連結到首頁. 要獲取更多關於圖像的資訊，使用者只須點擊藍色i圖示 即可. 若不利用此擴展，請輸入

帶有說明文字的複雜例子


上方的例子連接到許多頁面，取決於使用者點擊的位置. 要獲取更多資訊，點擊右下角雙矩形標誌.

Syntax description
The contents of an  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 " " or " " 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. All coordinates are according to the full-size image, not the visible image. They should be specified as distance from left edge (horizontal pixel count), distance from top (vertical pixel count).


 * desc : Specifies the location of a blue "i" icon [[Image:Desc-20.png|link=|alt=]], which links to the image description. Possible values: top-right, bottom-right (default), bottom-left, top-left, none. This parameter is ignored for " " or " " images, which instead employ the usual double-rectangle icon [[Image:Magnify-clip.png|link=|alt=]].


 * 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


 * 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 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.

Installation
Make sure that uploads and ImageMagick are installed:

$wgEnableUploads = true; $wgUseImageMagick = true; $wgImageMagickConvertCommand = "/usr/bin/convert";


 * 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  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
For MediaWiki 1.22+, you may install this extension using built-in Composer support. MediaWiki versions prior to 1.22 can use Composer via Extension:ExtensionInstaller.

composer require mediawiki/image-map @dev

Usage with templates, magic words, or parser functions.
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:


 * Example - with variable :


 * 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.

Where 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 will display the template at 400 pixels.

To convert the standard (existing) image maps to this optional format:
 * Replace the initial   with  }}  (the trailing braces).