Wikipedia:延伸图像语法
维库,知识与思想的自由文库
簡單來說,顯示圖像的語法是:
- [[Image:{名稱}|{類型}|{位置}|{尺寸}|{標題}]]
只有 [[Image:{名稱}]] 是必須的。大部分的圖像應該使用 [[Image:{名稱}|thumb|圖像標題範例]] (而且不應該指定尺寸)。其他細節是非必須的,且順序可以任意排列。
- 類型
- 'thumb' / 'thumbnail' 或 'frame'。Causes image to be displayed with specific formatting (see below).
- 位置
- 'right', 'left', 'center' 或 'none'。Determines placement of the image on the page. Defaults to 'right'.
- 尺寸
- {width}px or {width}x{height}px, scales the image to be no greater than the given width and height, keeping its aspect ratio.
- 標題
- Any element which cannot be identified as one of the above is assumed to be caption text.
Note that it doesn't matter whether the file is from Wikimedia Commons or on Wikipedia - the same syntax is used.
[编辑] 詳細的語法
[编辑] 類型
- "thumbnail" or "thumb": Image is scaled down to a standard, user specified width, by default 180 pixels, and a box is added around the image. If a caption is written, it is shown below the image. Image defaults to placement on the 'right' unless overridden with the 'Location' attribute (see above).
- "frame": Original image size is preserved, and a box is added around the image. If a caption is written, it is shown below the image.
- (nothing specified): Original image size is preserved, no border is added around the image. If a caption is written, it is not shown.
[编辑] 位置
- "right": Image including its box is placed on the right side of the page. The article text that follows the image flows around the image.
- "left": Image including its box is placed on the left side of the page. The article text that follows the image flows around the image.
- "center": Image including its box is placed in the center of the page. The article text that follows the image is placed below the image.
- "none": Image including its box is placed on the left side of the page. The article text that follows the image is placed below the image.
[编辑] 尺寸
- "100px": Scales the image down to make it 100 pixels wide. Replace any number for 100. If you specify "thumbnail" and a value here, this value will take precedent. If the image is already smaller than your specified value, the image stays at its size.
- "100x200px": Scales the image to be no wider than 100 pixels and no higher than 200 pixels. Image will keep its original aspect ratio
[编辑] 標題
Any element which cannot be identified as one of the above is assumed to be caption text.
[编辑] Syntax to use an image in uploaded size, with a caption
To use an image as uploaded with a caption use [[Image:Westminstpalace.jpg|frame|none|caption text]]. This is the syntax you should use to update images that used the original image markup of the form [[Image:Westminsterpalace.jpg|caption]]
[编辑] Syntax for images with no automatic caption or formatting
The old syntax for images without captions is [[Image:Westminstpalace.jpg|alt text]]. This is rendered inline, and the specified text is used as the image's alt attribute (alternate text for programs which cannot display images, such as screen readers) and as the title attribute (supplementary text, often displayed as a tool tip when the mouse is over the image).
See Wikipedia:Image markup with HTML for an old, deprecated, way of putting a caption under the image using HTML code. Please use the new way of associating captions with images, as described on this page.
See Wikipedia:Captions for discussion of appropriate caption text. See Wikipedia:Alternative text for images for discussion of appropriate alt text. Unfortunately, it is not possible to specify different text for these two purposes.
[编辑] Example
[编辑] New syntax for images
The new syntax is backward compatible, so articles don't have to be changed.
In the syntax [[Image:filename|options]] (e.g. [[Image:Westminstpalace.jpg|thumb|100px|left|The Palace of Westminster]] shown in the left), several options can be set when including an image. Those affect the placing of the image, its size or the way the image will be presented. The options are right, left, center, none, sizepx, thumbnail (thumb), frame, and alternate (caption) text.
The options can be combined, and vertical bars ("|") are used to separate options from each other. The options can be put in any order. An unknown option is taken as the caption text, but this seems to appear only if thumbnail is specified. If there are two or more unknown options, the last one upstages the rest: [[Image:Westminstpalace.jpg|thumb|The Palace of Westminster|200px|right|From the Thames]] (shown on the right).
Here is the description of the options other than the caption text:
- right
-
The image is right-aligned, and text floats to the left of the image: [[Image:Westminstpalace.jpg|right|70px|]] (shown on the right).
- left
-
The image is left aligned, and text floats to the right of the image: [[Image:Westminstpalace.jpg|left|70px|]] (shown on the left).
- center
- The image is centered, and...
the text following the image starts below it: [[Image:Westminstpalace.jpg|center|70px|]] (shown above).
- none
- The image is put at the left, and...
the text following does not float to the right (or to the left, obviously), and starts below it: [[Image:Westminstpalace.jpg|none|70px|]] (shown above).
-
- Notes:
- Notes:
-
-
The above four options are incompatible. When used combined, the last one overrides the rest: [[Image:Westminstpalace.jpg|none|right|center|left|70px|]] (shown on the left).
-
The above four options are incompatible. When used combined, the last one overrides the rest: [[Image:Westminstpalace.jpg|none|right|center|left|70px|]] (shown on the left).
-
-
What is between the last vertical bar and the closing brackets ("]]"), void or not, is taken as the last option, and works as usual. For instance, when the last option is right, the image is right-aligned, and text floats to the left: [[Image:Westminstpalace.jpg|70px|right]] (shown on the right).
-
What is between the last vertical bar and the closing brackets ("]]"), void or not, is taken as the last option, and works as usual. For instance, when the last option is right, the image is right-aligned, and text floats to the left: [[Image:Westminstpalace.jpg|70px|right]] (shown on the right).
-
-
In particular, if the last option is the void text (that is, if there is nothing between the last vertical bar and the closing brackets), the caption is not displayed: [[Image:Westminstpalace.jpg|thumb|This text is not displayed.|70px|left|]] (shown on the left) and [[Image:Westminstpalace.jpg|thumb|This text is displayed.|70px|right]] (shown on the right).
-
In particular, if the last option is the void text (that is, if there is nothing between the last vertical bar and the closing brackets), the caption is not displayed: [[Image:Westminstpalace.jpg|thumb|This text is not displayed.|70px|left|]] (shown on the left) and [[Image:Westminstpalace.jpg|thumb|This text is displayed.|70px|right]] (shown on the right).
- sizepx
-
This option renders a version of the image that's [size] pixels wide (e.g. [[Image:Westminstpalace.jpg|right|50px|]] shown on the right). Height is computed to keep aspect ratio (i.e. the shape of the image)
-
- Notes:
- Notes:
-
- Specifying a size does not just change the apparent image size using HTML; it actually generates a resized version of the image on the fly and links to it appropriately. This happens whether or not you use size in conjunction with thumb.
-
- This means the server does all the work of changing the image size, not the web browser of the user. By having the server do all the work means faster downloading of pages. It also means that larger images can be stored on the server without any slowdown by the browser (specially on dial up telephone lines.) Only the data for the actual size on the page is transmitted.
-
- If you specify a "frame" option the image will not be scaled, and no size specifiers will be in the HTML. The image will be rendered at full size
- If you specify a "frame" option the image will not be scaled, and no size specifiers will be in the HTML. The image will be rendered at full size
-
-
When there are two or more "size" options, only the last one is valid: [[Image:Westminstpalace.jpg|right|50px|80px]] (shown on the right).
-
When there are two or more "size" options, only the last one is valid: [[Image:Westminstpalace.jpg|right|50px|80px]] (shown on the right).
- thumbnail, thumb
- The thumbnail (thumb) option generates a thumbnail image. It is automatically resized when the "size" attribute is not specified. Without the options left, center, and none, the image is normally on the right. If the image has a caption text, it is displayed in the lower margin. E.g. [[Image:Westminstpalace.jpg|thumbnail|left|100px|]] (shown on the left) and [[Image:Westminstpalace.jpg|thumb|The Palace of Westminster]] (shown on the right). Note: thumbnail (thumb) cannot be used in lists.
An "enlarge"-icon is put also in the lower margin of the thumbnail. Both the image itself and the icon link to the image description page with the image in its actual size. The icon shows the link title "Enlarge" in its hoverbox, even in cases where this term does not apply, because it leads from the enlarged image to the one with the actual size. E.g. [[Image:tst.png|right|thumb|100px|This is a globe, and take a look at it in [[Media:tst.png|the actual size]].]] (shown on the right).
- frame
-
With this option, the embedded image is shown with its actual size enclosed by a frame, regardless of the "thumb" or "size" attribute, and the caption, if any, is visible in the frame. Without the options left, center, and none, the image is normally on the right: [[Image:Westminstpalace.jpg|frame|thumbnail|50px|The Palace of Westminster]].
With none of the options other than sizepx and alternate (caption) text, an embedded image is rendered inline.
text text text text text text [[Image:Westminstpalace.jpg|150px|The Palace of Westminster]] text text text text text [[Image:tst.png|100px|This is a globe.]] text text text text
gives
text text text text text text
text text text text text
text text text text
The option none can be used to have thumbnails without left- or right-alignment. This is probably most useful for tables. This is an example:
| How to use none | ||
|---|---|---|
| London's palaces | ||
| Palace of Westminster | [[Image:Westminstpalace.jpg|thumb|none|100px|From the Thames]] | |
| Buckingham Palace | [[Image:Buckingham palace Copyright2003KaihsuTai.jpg|thumb|none|100px|Queen's home]] | |
[编辑] Thumbnail with caption text underneath that has one or more links
From MediaWiki 1.3, it is also possible to include links in the caption text, e.g.:
[[Image:Westminstpalace.jpg|right|thumbnail|This is the [[Palace of Westminster]] in London]]
Just make sure the number of opening and closing square brackets are right. One extra or missing would mean the entire image syntax line would not work.
[编辑] 附加標題格式選擇
Additional caption formatting options are possible.
[[Image:Westminstpalace.jpg|right|thumbnail|<div align="center">這是'''在<span style="color: red">倫敦</span>'''<span style="color: green">的</span>[[西敏寺]]</div>]]
All of the normal text formatting options work.
[编辑] Compatibility considerations
The floating options left, center, and right explained above are supported by modern browsers, but have unfortunately no effect with legacy browsers. If necessary it's simple to get a floating effect also for old browsers:
{| align="right"
| [[Image:Westminstpalace.jpg|160px|Example]]
|}
This code is not intended for general use, however. There are few, if any, instances where support for such legacy browsers is necessary.
[编辑] Cancelling floating-around-image mode
After having had an image floating next to text, putting further text below it and again using the full width can be done with the following markup. This blocks an image from appearing next to the material following this markup, possibly due to aesthetic reasons or a change in topics.
- <br style="clear:both" />
For legacy align="right" (etc.) floating this isn't good enough; legacy browsers would ignore inline CSS. To cancel floating under all conditions the following markup (valid XHTML 1.0 transitional) works:
- <br clear="all" />
The same code can be issued by using template {{Clr}} or {{-}} in certain namespaces (En, meta).
[编辑] Linking to the image description page
If you want to make a link to the description page for an image, use a leading colon before "image:" in an intra-wiki link, like this: [[:image:STS-32 crew.jpg|STS-32 crew]] which yields: STS-32 crew
[编辑] 影像圖庫
[编辑] 參見
- Wikipedia:圖像 維基百科上圖像的概觀
- 維基共享資源 (共享首頁),一個自由的 多媒體儲存庫,你可以直接地使用在維基百科與其他的維基媒體專案上。你可以上載新的或使用已儲存的影像。
- Wikipedia:圖庫標籤 以新語法顯示多個圖像
- Wikipedia:圖像使用守則
- Wikipedia:圖片指南
- Wikipedia:找尋影像指南
- meta:Help:影像及其他上載的檔案





