帮助:图像
![]() |
注意:當您編輯本頁面時,即同意以CC0協議授權您的貢獻。您可以在公有領域帮助页面找到更多信息。 | ![]() |
这个页面解释了图片在编辑wiki时的语法。 在页面中,您或其它用户通常必须上传一张图片才能使用它。
图片被存储在MediaWiki服务器上通常通过使用File:
名字空间前缀(但传统的Image:
名字空间前缀仍然作为同义词受到支持)作为MediaWiki链接的目标。
Media:
名字空间前缀也可以作为替代用于链接用于引用原始媒体文件内容(在任何MediaWiki页面之外单独呈现或下载)。
必要条件
在页面使用图像之前,您Wiki的系统管理员必须开启文件上传且用户须要上传文件。 系统管理员可能也将Wiki设置为可使用外部存储库,例如:维基共享资源。 对于在服务器端的图像大小调整,则需要配置一个图形库(例如:GD2,ImageMagick等)。
支持的媒体类型
下面的文件格式默认被支持:
.jpg
或.jpeg
- 以标准JPEG格式压缩的位图图像(这种有损格式最适合于照片)。.png
- “便携式网络图形”格式的位图图像(由W3联盟指定)。.gif
- 传统“图形交换格式”中的位图图像。.webp
- WebP supports both lossy and lossless compression while reducing image size by up to 45%.
其他在维基媒体上和其他地方通常使用的格式(这超出安装时默认启用的类型,可能需要额外的步骤):
.svg
- 可扩展的图像“可缩放矢量图形”格式(由W3联盟指定)。 参见手册:图片管理#SVG。.tiff
- 标签图像格式。 常用于高分辨率档案照片。 通常与Extension:PagedTiffHandler 一同使用。.ogg
,.oga
,.ogv
- Ogg多媒体(音频或视频)。 不是一个图像格式,但对待方式类似。 通常与扩展:TimedMediaHandler 一同使用。.pdf
- 多页文档的便携文档格式(最初由Adobe指定)。 通常与Extension:PdfHandler 配合使用。.djvu
- DejaVu格式的多页面位图文档(通常是书本的扫描)。 参见Manual:How to use DjVu with MediaWiki- 一次只显示
.pdf
或.djvu
文件的单个页面。
- 一次只显示
其他媒体类型可能受支持,但可能无法以内联方式显示它们。
渲染单个图片
语法
显示图像的完整语法是:
[[File:filename.extension|options|caption]]
options可以不存在或者为以下内容,通过管道符号(|)分隔:
- 格式选项:border和frameless、frame(或framed)、thumb(或者是thumbnail)中的一个; Note: border can be used in combination with frameless but will be ignored if used with one of the other options.
- 控制呈现的图像应如何格式化并在页面的其余部分嵌入。
- 调整大小选项:下面列出中的一个
- {宽度}px——根据给定的最大宽度(以像素为单位)调整图像大小,不限制图像的高度。 (只支持整数像素值。 可以在宽度值和“px”之间添加一个空格。)
- x{高度}px——根据给定的最大高度(以像素为单位)调整图像大小,而不限制图像的宽度。 只支持整数像素值。 可以在寬度值和“px”之间添加一个空格。
- {宽度}x{高度}px——调整图像的大小以适应给定宽度和高度(以像素为单位)。 只支持整数像素值。 可以在宽度值和“px”之间添加一个空格。
- upright — ** upright——根据用户的喜好调整图像尺寸为适合合理的尺寸(适合高度大于宽度的图像)。 This option is often useful for images whose height is larger than their width. Requires either thumb or frameless. 选项
|upright=1.0|
会以用户的默认图像宽度显示图片。|upright=2.0|
会以用户默认图像宽度的2倍显示图片。
- 图像总是会保持它原有的长宽比例。
- 不可放缩的文件格式的图片可以被缩小,但不能被放大;例如,位图图像不能被放大。
upright
选项并不一定需要一个等号,也就是说,|upright 2.0|
和|upright=2.0|
效果相同。- 如果没有填入任何值或等号(例如,
|upright|
),默认视作|upright=0.75|
(但|upright=|
的效果相当于|upright=1.0|
)。 - 默认最大尺寸取决于“格式”和内部图像尺寸(根据其媒体类型)。
- 水平对齐选项:为left,right, center,none中的一个。 如果填入了多个选项,只有第一个会被使用。
- 在文本内控制图片的水平对齐(及行内/块状或浮动样式)(没有默认值)。
- 垂直对齐选项:为baseline、sub、super、top、text-top、middle、bottom、text-bottom中的一个;
- 在文本内控制非浮动行内图片的图片前后,以及同一块内的垂直对齐(默认的垂直对齐值为middle)。
- 链接选项:以下之一
- link={目标} —— 允许您更改生成的链接的目标(为任意页面标题或URL),可以从图像链接到;例如:
[[File:Example.jpg|20px|link=http://www.wikipedia.org]]
呈现为 (外部链接),或者是[[File:Example.jpg|20px|link=MediaWiki]]
呈现为 (内部链接)。 - link= (为空值) —— (MediaWiki 1.14+)显示图片且不显示链接;例如:
[[File:Example.jpg|20px|link=]]
呈现为 。
- 如果
link
和等于号之间有空格,则该语句会被视为普通的图片说明。 - 包含某些HTML字符等价,例如
%22
替代"
,可能导致整个语句被视为图片说明(参见phabricator:T306216)。 - !对于MW 1.24及其以下版本:若您设置了
|link=|
(为空),则不显示title
。(参见phabricator:T23454。)
- link={目标} —— 允许您更改生成的链接的目标(为任意页面标题或URL),可以从图像链接到;例如:
- 其它特定选项:
- alt={替代文本} —— (MediaWiki 1.14+)定义了若引用的图像无法下载和嵌入时的替代文本(映射到HTML元素
<img />
中的alt="..."
属性),或者是所支持的媒体必须使用使用替代描述文本(例如:使用盲文阅读器或用户浏览器中设置的辅助功能选项)。
- 如果
alt
和等于号之间有空格,则替代文字语句会被视为普通的图片说明。
- page={数字} —— 呈现指定的页码(当前仅使用于显示 .djvu 或 .pdf 文件)
- class={html类} —— (MediaWiki 1.20+)定义类(映射到生成的
<img />
元素的HTML属性class="..."
)。 - lang={语言代码}——(MediaWiki 1.22+)对于包含<switch>声明,与“系统语言”属性不同的SVG文件,选择渲染文件时使用的语言。 默认值总是英语,即便在非英语wiki上。
- alt={替代文本} —— (MediaWiki 1.14+)定义了若引用的图像无法下载和嵌入时的替代文本(映射到HTML元素
如果参数不符合任何其他的可能性,则将被认为是标题文本。 如果有多个非参数字符串,则图片说明中只会使用最后的非参数字符串。 标题文本在thumb 和 frame格式下在图片下方显示,其他格式下会作为提示文本显示。 在thumb 和 frame格式下显示的标题文本可能包含Wiki链接和其他格式。 MediaWiki扩展可以添加额外的选项。
若“alt”没有被指定且提供了标题,替代文字将从标题自动创建建而不进行格式化,除了自从字母已经由屏幕阅读者可读以来,在“thumb”或“frame”模式中的格式。
格式
下表显示了所有可用格式的效果。
当缩略图中图像的高度大于其宽度(即纵向而不是横向)时,如果图像的高度太大,可以尝试使用upright=N
,其中N是图像的纵横比(宽度除以其高度,默认为0.75)。
另一种方法是明确指定所需的最大高度(以像素为单位)。
注意,通过添加thumb={filename}
,您可以为缩略图使用不同的图像。
大小和框架
在不同的格式中,大小参数的效果可能不同,如下所示。
- 关于在未指定大小时的显示方式,请参阅上面的格式章节。
- 当格式没有指定或者只有
border
,图像的尺寸可以缩小或放大到所有指定的尺寸。 - 在下面的例子中,图像的原始尺寸为400×267像素。
- 带有
frame
时,图像将始终忽略指定的大小。原始图像的尺寸超过用户偏好中定义的最大尺寸时,则将会被缩小,页面信息将会显示一个Linter错误。 - 带有
thumb
或frameless
时,图像被可以减小,但不能放大超出图像的原始大小。
水平对齐
注意,当使用frame
或 thumb[nail]
格式时,对于从左向右书写的语言,图片是水平向右对齐的;对于从右向左书写的语言,图片水平向左对齐。
垂直对齐
垂直对齐选项仅在图像呈现为内联元素且不浮动时才能生效。 它们改变了内嵌图像在同一渲染行上的图像之前和/或之后与同一块中存在的文本垂直对齐的方式。
注意,插入内嵌图像显示的文本行(以及后面显示的文本行)可能会向下移动(这将通过增加行间距来增加行高度,就像使用span
标签设置字体大小参数的文本或者是带有上标或下标),以根据这个对齐约束来完全显示图像的高度。
<p style="border:1px solid #AAA;padding:0;font-size:150%;line-height:2">
<span style="background:#FFF;color:#000;text-decoration:overline"><u><del>text</del>
'''top:''' [[File:Example.jpg|20px|top]] [[File:Example.jpg|40px|top]] [[File:Example.jpg|100px|top]]
<del>text</del></u></span></p>
<p style="border:1px solid #AAA;padding:0;font-size:150%;line-height:2">
<span style="background:#FFF;color:#000;text-decoration:overline"><u><del>text</del>
'''text-top:''' [[File:Example.jpg|20px|text-top]] [[File:Example.jpg|40px|text-top]] [[File:Example.jpg|100px|text-top]]
<del>text</del></u></span></p>
<p style="border:1px solid #AAA;padding:0;font-size:150%;line-height:2">
<span style="background:#FFF;color:#000;text-decoration:overline"><u><del>text</del>
<sup>super:</sup> [[File:Example.jpg|20px|super]] [[File:Example.jpg|40px|super]] [[File:Example.jpg|100px|super]]
<del>text</del></u></span></p>
<p style="border:1px solid #AAA;padding:0;font-size:150%;line-height:2">
<span style="background:#FFF;color:#000;text-decoration:overline"><u><del>text</del>
'''baseline:''' [[File:Example.jpg|20px|baseline]] [[File:Example.jpg|40px|baseline]] [[File:Example.jpg|100px|baseline]]
<del>text</del></u></span></p>
<p style="border:1px solid #AAA;padding:0;font-size:150%;line-height:2">
<span style="background:#FFF;color:#000;text-decoration:overline"><u><del>text</del>
<sub>'''sub:'''</sub> [[File:Example.jpg|20px|sub]] [[File:Example.jpg|40px|sub]] [[File:Example.jpg|100px|sub]]
<del>text</del></u></span></p>
<p style="border:1px solid #AAA;padding:0;font-size:150%;line-height:2">
<span style="background:#FFF;color:#000;text-decoration:overline"><u><del>text</del>
'''default:''' [[File:Example.jpg|20px]][[File:Example.jpg|40px]] [[File:Example.jpg|100px]]
<del>text</del></u></span></p>
<p style="border:1px solid #AAA;padding:0;font-size:150%;line-height:2">
<span style="background:#FFF;color:#000;text-decoration:overline"><u><del>text</del>
'''middle:''' [[File:Example.jpg|20px|middle]] [[File:Example.jpg|40px|middle]] [[File:Example.jpg|100px|middle]]
<del>text</del></u></span></p>
<p style="border:1px solid #AAA;padding:0;font-size:150%;line-height:2">
<span style="background:#FFF;color:#000;text-decoration:overline"><u><del>text</del>
'''text-bottom:''' [[File:Example.jpg|20px|text-bottom]] [[File:Example.jpg|40px|text-bottom]] [[File:Example.jpg|100px|text-bottom]]
<del>text</del></u></span></p>
<p style="border:1px solid #AAA;padding:0;font-size:150%;line-height:2">
<span style="background:#FFF;color:#000;text-decoration:overline"><u><del>text</del>
'''bottom:'' [[File:Example.jpg|20px|bottom]] [[File:Example.jpg|40px|bottom]] [[File:Example.jpg|100px|bottom]]
<del>text</del></u></span></p>
为了更清晰地显示对齐结果,文本被添加上划线和下划线,字体大小增加到200%,并且用细边框勾勒段落块;另外不同大小的图像是成一条线的:
备注:
- 图片位置的“居中”垂直对齐(即默认值)通常是指位于x高度和文本基线中央(图像的垂直中心会对齐到x高度,文本书写与文本基线上),但并不是对齐到字体高度的行高的中央(即“文本顶部”和“文本底部”位置之间的空格);字体高度不包括:
- 额外的行距(line separation spacing)通常被均分为字体高度上方和下方的两个行边距(line-margins),这里是0.5em,根据设置为200%的行高。
- 可能被上下标添加的额外行距。
- 然而,如果图像高度导致顶部或底部位置超过正常完整文本行高之上或之下,则中央位置会在增加顶部/底部行间距后进行调整,这样图片可以适当地适应和对齐,且所有图片(包括高度较小的)将垂直居中于文本调整中间位置(为了计算有效行高,会考虑每行字体高度较大的文本)。
- “文本顶部”和“文本底部”对齐位置也不包括由上下标添加的额外行距,但没有由行高定义的额外的行距。
- “顶部”与“底部”对齐位置会考虑所有的额外的行距(包括上下标,如果渲染的行范围中存在)。 当图像对齐将图像限制在正常行距之上或之下增长,且图像不是绝对定位时,图像将导致调整“顶部”和“底部”位置(就像上标和下标一样),因此文本的渲染行之间的有效行高会更高。
- “下划线”“上划线”“删除线”这些文本装饰(text-decoration),一般是在这两个限制之内的,“可能会”取决于使用的字体的类型和高度(部分浏览器会考虑上下标,但通常这些样式会被忽略,文本装饰的位置也不会调整);所以这些文本装饰通常不会影响图像相对文本的垂直位置。
停止文本流
有时需要阻止文本(或其他内联非浮动图像)在浮动图像周围流动。
根据web浏览器的屏幕分辨率或者类似的,图像右侧的文本流可能导致段落标题(例如,== 我的标题 ==)出现在图像的右侧,而不是像用户想看到的那样出现在图像下方。
可以通过在需要在浮动图像之下开始的文本之前放置<br clear=all>
(或者,如果你愿意,也可以<div style="clear: both"></div>
)来阻止文本流。
(也可以通过将带有浮动图片的段落包装在<div style="overflow: hidden">…</div>
中来做到这样而无需添加新行,这会清除div
元素内的所有浮动。)
所有渲染为块的图像(包括非浮动的中央图像、左浮或右浮的图像,以及有框架或缩略图的浮动图像)都会不明显地打断周围文本行(中止图片前文本的当前块,为其后的文本创建新的段落)。 然后,这些图像就会沿着左侧或右侧对齐边距(或者沿着居中对齐图像的这些边距之间的中心行)垂直堆叠。
修改默认链接目标
下表显示了如何更改链接目标(默认为图像说明页面)或如何移除它。 更改链接不会改变前面部分中描述的格式。
描述 | 您输入的 | 您输出的 |
---|---|---|
内部链接 |
... 文本 文本 文本 [[File:example.jpg|link=Main Page|标题]] 文本 文本 文本 ... |
... 文本 文本 文本 |
外部链接 |
... 文本 文本 文本 [[File:example.jpg|link=http://wikipedia.org/wiki/Test|标题]] 文本 文本 文本 ... |
... 文本 文本 文本 |
无链接(外部链接或文件页面) |
... 文本 文本 文本 [[File:example.jpg|link=|标题]] 文本 文本 文本 ... |
... 文本 文本 文本
文本 文本 文本 ... |
警告:
- The licencing requirements on your wiki may not allow you to remove all links to the description page that displays the required authors attributions, the copyrights statements, the applicable licencing terms, or a more complete description of the rendered image (including its history of modifications).
- If you change or remove the target link of an image, you will then have to provide somewhere else on your page an explicit link to this description page, or to display the copyright and author statement and a link to the applicable licence, if they are different from the elements applicable to the embedding page itself.
- Your wiki policy may restrict the use of the alternate link parameter, or may even enforce a prohibition of alternate link parameters for embedded media files (in which case, the link parameter will be ignored), or may only accept them after validation by authorized users or administrators.
渲染一系列图片的图库
图库语法
使用<gallery>
标签制作缩略图图库很容易。
语法为:
<gallery>
File:file_name.ext|caption|alt=alt language
File:file_name.ext|caption|alt=alt language
{...}
</gallery>
注意,在gallery标签中图片代码没有使用中括号括起来。
标题是可选的,其可以包含Wiki链接或其他格式。
控制图片显示的一些参数也可以在这里使用,特别是那些修改文件的参数(与控制图像在页面中的位置不同)。
例如:带有多个页面的PDF文档,您可以使用像page=4
这样的代码。
File:
前缀可以被省略。
However, it is helpful to include it as an aid for quickly locating image specifiers in the wikitext (for example, when cleaning up page layout).
例如:
<gallery>
File:Example.jpg|Item 1
File:Example.jpg|a link to [[Help:Contents]]
File:Example.jpg
File:Example.jpg|alt=An example image. It has flowers
File:Example.jpg|''italic caption''
File:Example.jpg|Links to external website|link=https://example.com
File:Example.jpg|link=w:Main_Page|Internal link
Example.jpg|on page "{{PAGENAME}}"
File:Using Firefox.pdf|page=72
</gallery>
会被格式化为:
-
Item 1
-
a link to Help:Contents
-
-
-
italic caption
-
Links to external website
-
Internal link
-
on page "Images/zh"
-
mode参数
MediaWiki版本: | ≥ 1.22 |
自1.22版本开始,我们有了一个实验性的mode
参数,采取如下选项:
traditional
是MediaWiki使用的最初的图库类型。nolines
与traditional
相似,但不包含边框。packed
使图像拥有相同的高度但是宽度不同,图像之间的空隙很小。 这个响应模式中的行根据屏幕的宽度自行组织。packed-overlay
用一个半透明的白框将标题覆盖显示在图像上。packed-hover
与packed-overlay
相似,但图片标题和白框只在悬停时显示。slideshow
用幻灯片形式展现图像。
例如:
<gallery mode="packed-hover">
Image:Astronotus_ocellatus.jpg|''[[commons:Astronotus ocellatus|Astronotus ocellatus]]'' (Oscar)
Image:Salmonlarvakils.jpg|''[[commons:Salmo salar|Salmo salar]]'' (Salmon Larva)
Image:Georgia Aquarium - Giant Grouper.jpg|''[[commons:Epinephelus lanceolatus|Epinephelus lanceolatus]]'' (Giant grouper)
Image:Pterois volitans Manado-e.jpg|''[[commons:Pterois volitans|Pterois volitans]]'' (Red Lionfish)
Image:Macropodus opercularis - front (aka).jpg|''[[commons:Macropodus opercularis|Macropodus opercularis]]'' (Paradise fish)
Image:Canthigaster valentini 1.jpg|''[[commons:Canthigaster valentini|Canthigaster valentini]]'' (Valentinni's sharpnose puffer)
Image:Flughahn.jpg|[[Image:POTY ribbon 2007.svg|25px]] ''[[commons:Dactylopterus volitans|Dactylopterus volitans]]'' (Flying gurnard)
Image:Fishmarket 01.jpg|''[[commons:Semicossyphus pulcher|Semicossyphus pulcher]]'' (California Sheephead)
Image:Pseudorasbora parva(edited version).jpg|''[[commons:Category:Pseudorasbora parva|Pseudorasbora parva]]'' (Topmouth gudgeon)
Image:MC Rotfeuerfisch.jpg|''[[commons:Category:Pterois antennata|Pterois antennata]]'' (Antennata Lionfish)
Image:Cleaning station konan.jpg|''[[commons:Novaculichthys taeniourus|Novaculichthys taeniourus]]''
Image:Synchiropus splendidus 2 Luc Viatour.jpg|''[[commons:Synchiropus splendidus|Synchiropus splendidus]]'' (Mandarin fish)
File:Psetta maxima Luc Viatour.jpg|''[[commons:Psetta maxima|Psetta maxima]]'' (Turbot)
File:Australian blenny.jpg|''[[commons:Category:Ecsenius|Ecsenius axelrodi]]''
</gallery>
使用(packed-hover
选项):
-
Astronotus ocellatus (Oscar)
-
Salmo salar (Salmon Larva)
-
Epinephelus lanceolatus (Giant grouper)
-
Pterois volitans (Red Lionfish)
-
Macropodus opercularis (Paradise fish)
-
Canthigaster valentini (Valentinni's sharpnose puffer)
-
Dactylopterus volitans (Flying gurnard)
-
Semicossyphus pulcher (California Sheephead)
-
Pseudorasbora parva (Topmouth gudgeon)
-
Pterois antennata (Antennata Lionfish)
-
Synchiropus splendidus (Mandarin fish)
-
Psetta maxima (Turbot)
使用其他选项的例子:
mode="traditional"
-
Astronotus ocellatus (Oscar)
-
Salmo salar (Salmon Larva)
-
Epinephelus lanceolatus (Giant grouper)
mode="nolines"
-
Astronotus ocellatus (Oscar)
-
Salmo salar (Salmon Larva)
-
Epinephelus lanceolatus (Giant grouper)
mode="packed"
-
Astronotus ocellatus (Oscar)
-
Salmo salar (Salmon Larva)
-
Epinephelus lanceolatus (Giant grouper)
mode="packed-overlay"
mode="packed-hover"
-
Astronotus ocellatus (Oscar)
-
Salmo salar (Salmon Larva)
-
Epinephelus lanceolatus (Giant grouper)
MediaWiki版本: | ≥ 1.28 |
mode="slideshow"
可选的图库属性
The gallery tag itself takes several additional parameters, specified as attribute name-value pairs:
<gallery {parameters}>
{images}
</gallery>
caption="{caption}"
: (caption text between double quotes for more than a word) sets a caption centered atop the gallery. Only plain text may be used in the caption; formatting, templates and the like will not work.
widths={width}px
: sets the (max) widths of the images; the default value is 120px.
(It has no effect if mode is set to one of the following: packed, packed-overlay, packed-hover, slideshow.) 注意复数:widths.
heights={heights}px
: sets the (max) heights of the images; the default value is 120px.
(It has no effect if mode is set to slideshow.)
perrow={integer}
: sets the number of images per row.
(It has no effect if mode is set to one of the following: packed, packed-overlay, packed-hover, slideshow.) 0 means automatically adjust based on width of screen.
showfilename={anything}
: Show the filenames of the images in the individual captions for each image (1.17+).
mode={traditional|nolines|packed|packed-hover|packed-overlay|slideshow}
: See section above (1.22+; 1.28+ for "slideshow").
showthumbnails
: For "slideshow" mode only, display the strip with image thumbnails below the slideshow by default (1.29+).
- Example 1
Syntax:
<gallery widths=300px heights=200px>
File:Example.jpg|Lorem ipsum
File:Example.jpg|Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut
</gallery>
Result:
-
Lorem ipsum
-
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut
- 範例2
Syntax:
<gallery widths=60px heights=60px perrow=7 caption="sunflowers are groovy">
File:Example.jpg
File:Example.jpg
File:Example.jpg
File:Example.jpg
File:Example.jpg
File:Example.jpg
File:Example.jpg
File:Example.jpg
File:Example.jpg
File:Example.jpg
</gallery>
结果:
- sunflowers are groovy
-
-
-
-
-
-
-
-
-
-
将包裹至浏览器宽度的图片行
One way that works for a row of images with varying widths is not to use "thumb" or "left" or "none". If "thumb" is not used (and thus no captions) a row of images will wrap to the browser width. If necessary, narrow the browser window to see the images wrap to the next row.
[[File:Example.jpg|220px]] [[File:Example.jpg|100px]] [[File:Example.jpg|150px]] [[File:Example.jpg|250px]] [[File:Example.jpg|200px]] [[File:Example.jpg|50px]] [[File:Example.jpg|220px]] [[File:Example.jpg|175px]]
To wrap images of varying widths with captions it is necessary to use div HTML for an unordered list. Along with style="display: inline-block;"
. For more info and ideas see: Give Floats the Flick in CSS Layouts.
<div><ul>
<li style="display: inline-block;"> [[File:Example.jpg|thumb|none|220px|Caption 1]] </li>
<li style="display: inline-block;"> [[File:Example.jpg|thumb|none|100px|Caption 2]] </li>
<li style="display: inline-block;"> [[File:Example.jpg|thumb|none|150px|Caption 3]] </li>
<li style="display: inline-block;"> [[File:Example.jpg|thumb|none|250px|Caption 4]] </li>
<li style="display: inline-block;"> [[File:Example.jpg|thumb|none|200px|Caption 5]] </li>
<li style="display: inline-block;"> [[File:Example.jpg|thumb|none|50px|Caption 6]] </li>
<li style="display: inline-block;"> [[File:Example.jpg|thumb|none|220px|Caption 7]] </li>
<li style="display: inline-block;"> [[File:Example.jpg|thumb|none|175px|Caption 8]] </li>
</ul></div>
To align the top edge of images add the vertical-align command
<div><ul>
<li style="display: inline-block; vertical-align: top;"> [[File:Example.jpg|thumb|none|220px|Caption 1]] </li>
<li style="display: inline-block; vertical-align: top;"> [[File:Example.jpg|thumb|none|100px|Caption 2]] </li>
<li style="display: inline-block; vertical-align: top;"> [[File:Example.jpg|thumb|none|150px|Caption 3]] </li>
<li style="display: inline-block; vertical-align: top;"> [[File:Example.jpg|thumb|none|250px|Caption 4]] </li>
<li style="display: inline-block; vertical-align: top;"> [[File:Example.jpg|thumb|none|200px|Caption 5]] </li>
<li style="display: inline-block; vertical-align: top;"> [[File:Example.jpg|thumb|none|50px|Caption 6]] </li>
<li style="display: inline-block; vertical-align: top;"> [[File:Example.jpg|thumb|none|220px|Caption 7]] </li>
<li style="display: inline-block; vertical-align: top;"> [[File:Example.jpg|thumb|none|175px|Caption 8]] </li>
</ul></div>
Some wiki farms do not have all gallery options (such as "widths"). Also, sometimes one wants varying widths for images in a row. Outside of a gallery, or the div HTML, it is impossible to have individual captions for images in a row of images that will wrap to the browser width. Try it and see. Nothing else using wikitext works correctly. Images will either overlap stuff on the right, or force a horizontal scroll bar.
Using a left float ("left") for some images, combined with "none" for some of the images, will not work consistently either, especially if there is also a right sidebar of images. Weird things will occur. At narrower browser or screen widths an image out of the row may appear far down the page after the end of the right sidebar of images.
链接行为
默认情况下图片是链接到他的描述页面的。 “link=”选项可以修改这个行为将图片链接的另一个页面或网站,或是关闭图片的链接行为。
另外,您可以创建一个文本链接到文件描述页面或文件本身。 参见Help:链接到文件 。
显示图片,链接至另一页面或网站
使用“link=”选项链接图像到另一个页面或网站:
点击下方的图像将会引导您到MediaWiki页面:
[[File:MediaWiki-2020-logo.svg|50px|link=MediaWiki]]
点击下方的图像将会带您到example.com:
[[File:MediaWiki-2020-logo.svg|50px|link=http://example.com]]
显示关闭链接的图像
使用“link=”选项而不对齐赋值来完全关闭链接;下方是不带链接的图像:
[[File:MediaWiki-2020-logo.svg|50px|link=]]
链接到图像
添加:
作为前缀到您要创建的链接前:
[[:File:MediaWiki-2020-logo.svg]]
[[:File:MediaWiki-2020-logo.svg|Wiki]]
Directly linking to an image
The above examples link to the image's description page.
To directly link to an image, the pseudo-namespace Media:
can be used on MediaWiki pages:
[[Media:MediaWiki-2020-logo.svg]]
Direct links from external sites
Another possibility is to use the Special:Redirect/file page (or its alias Special:Filepath). Unlike the above example, you can link to it from external websites as well as from MediaWiki pages.
[[Special:Redirect/file/Wikipedia.png]]
The parameters height
and width
can also be added to return a specific size of the image.
The image aspect ratio is always preserved.
https://www.mediawiki.org/w/index.php?title=Special:Redirect/file/Wikipedia.png&width=100&height=100
Obtaining the full URL of an image
To obtain the full path of an image (without going through redirects as shown above), some 魔术字 can be used.
{{filepath:MediaWiki-2020-logo.svg}}
Becomes:
- //upload.wikimedia.org/wikipedia/commons/d/dd/MediaWiki-2020-logo.svg
In the event that this is used from a template where the File:
namespace needs to be removed, {{PAGENAME}}
can do so:
{{filepath:{{PAGENAME:File:MediaWiki-2020-logo.svg}}}}
Becomes:
- //upload.wikimedia.org/wikipedia/commons/d/dd/MediaWiki-2020-logo.svg
在其他网站的图片
您可以使用链接到外部网页的相同方式链接到可在线获取的外部文件。 带有这些句法,图像将不会被渲染,但是只有链接到这个图像的文本才会被显示。
[http://url.for/some/image.png]
或显示不同的文字:
[http://url.for/some/image.png 在此输入链接文本]
额外的MediaWiki标记或HTML/CSS格式(对于内联元素)允许在显示文本中使用(除破坏周围链接的嵌入式链接外):
[http://www.example.com/some/image.png 这里是'''<del>富</del>'''''<ins>文本链接</ins>''示例。]
which renders as:
若这在您的Wiki上启用了(参见手册:$wgAllowExternalImages ),您可以嵌入外部图像。要这样做,只需插入图片网址:
http://url.for/some/image.png
目前,嵌入式图像无法调整大小,但可以通过MediaWiki标记或HTML/CSS代码进行格式化。
如果此Wiki未启用该选项,则图像将不会被嵌入,而会以与上述相同的方式呈现为外部网站的文本链接。