Jump to content

手册:链接图像

From mediawiki.org
This page is a translated version of the page Manual:Linked images and the translation is 32% complete.
Outdated translations are marked like this.

默认情况下,MediaWiki wiki上的图像将链接到描述页,以便用户在单击图像时可以立即获得许可信息、上传历史记录、贡献者和全分辨率版本。

然而,对于那些需要它们的人,有几种变通方法。

link= syntax

可以使用Help:图片 的语法从图像直接进行内部或外部链接。


在您的Wiki代码中:

[[Image:Wiki.png|50px|link=MediaWiki]]

这将制作一张50像素宽的图片,并链接到页面MediaWiki

如果链接为空,则图像将不再可单击。

[[Image:Wiki.png|50px|link=]]


External image syntax

If you enable $wgAllowExternalImages (which allows external images from any domain) or $wgAllowExternalImagesFrom (which restricts the list of domains), anyone can then easily create an "external" link to an "external" image. External simply means: using the full URL rather than a local link, so you can link locally, but you need to use the full URL. The plainlinks class is used to remove the "external link" icon:

After enabling $wgAllowExternalImages , you can also embed an image by simply typing the URL of the image.

For example,
https://domain.com/images/image_file.png
will display the image on screen.
<span class="plainlinks">[https://linktopage https://linktoimage]</span>

So for example, were external images allowed here, you could link to the main page with https://upload.wikimedia.org/wikipedia/mediawiki/b/bc/Wiki.png using wikicode like:

<span class="plainlinks">[{{fullurl:MediaWiki}} https://upload.wikimedia.org/wikipedia/mediawiki/b/bc/Wiki.png]</span>

This has the disadvantage of not registering the link, or the image use, as well as not being easily portable to forks and mirrors.

Raw HTML

If you enable $wgRawHtml , you can use ‎<img> tags freely, but this method is highly insecure. On prior versions of MediaWiki you could have used the 手册:$wgAllowImageTag (在版本1.42移除) option which allows <img> and is more secure than raw HTML.

There are, however, some extensions to make it safer, see 手册:$wgRawHtml for details.

ImageMap extension

扩展:ImageMap can be deployed to enable more advanced customization of where an image links to, such as specific pixels pointing to specific places.

参见