Extension:ImageMap

From mediawiki.org
This page is a translated version of the page Extension:ImageMap and the translation is 31% complete.
この拡張機能は MediaWiki 1.21 以降に同梱されています。 そのため再度ダウンロードする必要はありません。 しかし、提供されているその他の手順に従う必要はあります。
MediaWiki 拡張機能マニュアル
ImageMap
リリースの状態: 安定
実装 タグ
説明 クリックできるHTMLイメージマップをつくる
作者 Tim Starlingトーク
最新バージョン 継続的な更新
MediaWiki 1.23+
PHP 5.4+
Composer mediawiki/image-map
ライセンス GNU 一般公衆利用許諾書 2.0 以降
ダウンロード
log
Children's encyclopedia
Quarterly downloads 101 (Ranked 64th)
Public wikis using 10,714 (Ranked 16th)
translatewiki.net で翻訳を利用できる場合は、ImageMap 拡張機能の翻訳にご協力ください
問題点 未解決のタスク · バグを報告

ImageMap拡張機能を使うと、クリックできるイメージマップをつくることができます。 イメージマップは、特定の画像内にある座標のリストで、それらによって指定された各領域それぞれに対し異なるリンク先にハイパーリンクが設定できます(画像の領域全体が単一の宛先に対しリンクされている通常の画像リンクとは対照的です)。 例えば、世界地図では、国ごとにその国に関する詳細な情報へのハイパーリンクが張られていることがあります。 イメージマップは、画像を個別の画像ファイルに分割することなく、画像のさまざまな部分に対し簡単にリンクを設定する方法を提供することを目的としています。


説明文のない単純な例

<imagemap>
File:Example2.png|150px|alt=代替テキスト
default [[Main Page|メインページに行く]]
</imagemap>
代替テキスト

上の例では、図内のどの部分をクリックしても Main Page にリンクしています。画像に関するより詳しい情報を見るには、青い "i" のアイコン をクリックしてください。 この拡張機能を使わずにこのようにリンクが設定された画像をつくるには、[[File:Example2.png|150px|alt=Alt text|title=メインページに行く|link=メインページ]] のようなhtmlコードを記します。

説明文付きの複雑な例

この例では、幅500ピクセル、高さ250ピクセルのサムネイルを表示します。元画像の大きさは 9,600 x 4800 ピクセルです。 各頂点は、元画像内の点を指す座標をピクセル単位で指定します。 例えば、「ユダ」(画像の右端から2番目)をとり囲む多角形の頂点は、水平座標(左からのピクセル数で計測)が1$、垂直座標(上からのピクセル数で計測)が2$となり、500×250 サイズのサムネイル表示範囲からは大きく外れているものの、9600×4800の元画像では範囲内に入っています。 なお、「シモン」(画像右端)をとり囲む多角形の頂点のうち、座標9625 3301の頂点は、元画像の範囲9,600×4,800の外にあることに注意してください。

<imagemap>
File:The Last Supper - Leonardo Da Vinci - High Resolution 32x16.jpg|thumb|center|500px|alt=''最後の晩餐'' レオナルド・ダ・ヴィンチ作 - クリッカブルイメージ|イメージマップの例。 絵の中の人物をクリックすると、その人に関する記事がブラウザに読み込まれます。

poly 550 2550 750 2400 1150 2300 1150 2150 1200 2075 1500 2125 1525 2300 1350 2800 1450 3000 1700 3300 1300 3475 650 3500 550 3300 450 3000 [[w:Bartholomew the Apostle|Bartholomew]] 
poly 1575 2300 1625 2150 1900 2150 1925 2500 1875 2600 1800 2750 1600 3250 1425 3100 1400 2800 1375 2600 [[w:James, son of Alphaeus|James Minor]]
poly 1960 2150 2200 2150 2350 2500 2450 2575 2375 2725 2375 2900 2225 3100 2225 3225 1600 3225 1825 2700 1975 2450 1925 2300 [[w:Saint Andrew|Andrew]]
poly 2450 2575 2775 2500 2700 2650 2800 2700 2600 3000 2600 3250 2300 3250 2200 3200 2300 3000 [[w:Saint Peter|Peter]]
poly 2750 2500 2950 2400 3125 2600 3175 2700 3300 2850 3700 3200 3750 3200 3650 3350 3400 3200 3000 3350 2600 3325 2750 2800 2900 2700 2700 2650 [[w:Judas Iscariot|Judas]]
poly 3000 2350 3300 2350 3350 2660 3560 2600 3565 2690 3250 2800 3125 2575 [[w:Saint Peter|Peter]]                                     
poly 3332 2338 3528 2240 4284 3024 4074 3332 3864 3290 3780 3150 3668 3192 3598 3024 3374 2870 3388 2772 3542 2800 3668 2702 3542 2590 3430 2604 3350 2600 3300 2500[[w:John the Apostle|John]]
poly 4775 2184 4915 2128 5055 2212 5083 2352 5111 2464 5181 2604 5307 2744 5573 3052 5615 3192 5657 3290 5573 3402 5461 3332 5335 3248 4495 3248 4439 3388 4243 3388 4075 3360 4173 3136 4327 3010 4509 2730 4663 2520 4733 2394 [[w:Jesus]]
poly 5900 2100 5900 2150 5800 2400 5800 2500 5675 2589 5480 2671 5438 2507 5425 2301 5589 2452 5630 2301 5650 2100 [[w:Thomas the Apostle|Thomas]]
poly 5918 2150 6041 2109 6137 2246 6192 2411 6110 2589 6110 2726 6192 2822 6302 2740 6589 3109 5658 3178 5575 2918 5300 2698 5233 2589 5274 2438 5370 2507 5521 2685 5617 2671 5712 2575 5822 2507 5808 2287 5822 2175 [[w:James, son of Zebedee|James Greater]]
poly 6137 2013 6439 2013 6863 2260 7110 2515 6726 2675 6507 2548 6425 2630 6356 2753 6548 2849 6699 2781 7082 2794 7178 3109 6699 3178 6548 2986 6397 2835 6165 2775 6110 2589 6233 2438 6302 2383 6151 2287 6096 2164 [[w:Philip the Apostle|Philip]]
poly 7635 2123 7800 2013 8000 2055 8025 2287 7950 2438 8000 2698 8055 2918 7959 3164 7233 3164 7124 2972 7124 2794 6548 2794 6384 2781 6384 2671 6493 2575 6750 2650 7075 2550 7219 2400 7625 2300 [[w:Matthew the Apostle|Matthew]]
poly 8325 2096 8600 2109 8635 2493 8615 2726 8439 2781 8274 2740 8125 2835 8151 2931 8400 2975 8411 3068 8589 3041 8617 3205 7987 3260 8124 3027 7987 2644 7904 2493 7959 2425 8096 2356 [[w:Judas Thaddaeus|Jude]]
poly 8800 2150 8900 2125 9055 2150 9125 2397 9400 2475 9550 2931 9625 3301 9151 3397 8535 3219 8726 3014 8466 3068 8411 2918 8178 2931 8124 2835 8329 2753 8535 2794 8726 2603 8725 2342 [[w:Simon the Zealot|Simon]]
</imagemap>
最後の晩餐 レオナルド・ダ・ヴィンチ作 - クリッカブルイメージBartholomewJames MinorAndrewPeterJudasPeterJohnw:JesusThomasJames GreaterPhilipMatthewJudeSimon
イメージマップの例。 絵の中の人物をクリックすると、その人に関する記事がブラウザに読み込まれます。

上の例は、クリックする場所によって、さまざまなページにリンクしています。画像の詳細を確認するには、四角形が2つ重なったアイコンをクリックしてください。

書式の説明

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.
<imagemap>
File: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.

インストール

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";
  • ダウンロードして、ファイルをextensions/フォルダー内のImageMapという名前のディレクトリ内に配置します。
    Developers and code contributors should install the extension from Git instead, using:cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/ImageMap
  • 以下のコードを LocalSettings.php ファイルの末尾に追加します:
    wfLoadExtension( 'ImageMap' );
    
  • Yes 完了 – ウィキの「Special:Version」に移動して、拡張機能が正しくインストールされたことを確認します。
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).
  3. On OVH mutualized hosting $wgUseImageMagick should be like: $wgUseImageMagick=false;

Composer

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

composer require mediawiki/image-map @dev
Using Composer to install this extension will cause installation of the latest development version of this extension each time you do a "composer update --no-dev" command.


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:
<imagemap>
File:ExamplePlant80.png|60px|ExamplePlant
rect 0 107 294 260 [[Plants/ExamplePlant|ExamplePlant]]
desc none
</imagemap>
Example - with variable {{PAGENAME}}
{{#tag:imagemap|
File: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).


関連項目

Instructions
Wiki tools
Online tools
Similar functionalities