(→Supported media types for images: add ogg to this list) |
m (1 revision: Import MediaWiki help files) |
| Important note: When you edit this page, you agree to release your contribution into the public domain. If you don't want this or can't do this because of license restrictions, please don't edit. This page is one of the Public Domain Help Pages, which can be freely copied into fresh wiki installations and/or distributed with MediaWiki software; see Help:Contents for an overview of all pages. See Project:PD help/Copying for instructions. |
This page explains the image syntax when editing the wiki. You or another user must usually upload an image before you can use it on a page.
Images that are stored on a MediaWiki server are usually rendered by using the File: namespace prefix (but the legacy Image: namespace prefix is still supported as a synonym) as the target of a MediaWiki link. The alternate Media: namespace prefix is also usable to reference the original media file content (for rendering or downloading it separately, out of any MediaWiki page).
Contents |
The following file formats are supported by Mediawiki by default:
Other formats used on Wikimedia, and commonly enabled elsewhere (These may require extra set up beyond what is enabled by default):
Other media types may be supported depending on how Mediawiki is set up. Typically they can be uploaded but not displayed inline unless a helper extension is installed.
The full syntax for displaying an image is:
[[File:file name.extension|options|caption]]
where options can be zero or more of the following, separated by pipes (|):
[[File:Example.jpg|20px|link=]] renders as alt="..." of the generated <image /> element) of an image that will be rendered if either the referenced image cannot be downloaded and embedded, or if the support media must use the alternative description text (e.g. when using a Braille reader or with accessibility options set by the user in its browser).
The options can be given in any order. If the given options conflict each other, the latter is applied, except for the format options, where the options take the priority in the order of: frame; thumb (or thumbnail); frameless and/or border.
If a parameter does not match any of the other possibilities, it is assumed to be the caption text. Caption text shows below the image in thumb and frame formats, or as mouseover text in border, frameless formats or when the format is omitted. Caption text displayed in the thumb and frame formats may contain wiki links and other formatting. In the other options, wiki-formatting will not work though transclusion will.
If no caption text is supplied, a caption is automatically created showing the file name. To completely remove the caption, set it to <span title=""></span>. For example, [[File:Example.jpg|20px|<span title=""></span>]] renders as
.
The following table shows the effect of all available formats.
| Description | You type | You get |
|---|---|---|
| no format specified|}}{{#if:no| Rendered as a floating block: no|}}{{#if:yes| Rendered inline: yes|}} |
... text text text
[[File:example.jpg{{#if:||'}}{{#if:||'{{{2}}}}}{{#if:|{{#ifeq:|none|||}}||caption}}]]
text text text ...
| wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text |
| border results in a very small gray border|border}}{{#if:no| Rendered as a floating block: no|}}{{#if:yes| Rendered inline: yes|}} |
... text text text
[[File:example.jpg{{#if:border||border}}{{#if:||{{{2}}}}}{{#if:|{{#ifeq:|none|||}}||caption}}]]
text text text ...
| wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text |
| frameless, like thumbnail, respect user preferences for image width, but without border and no right float|frameless}}{{#if:no| Rendered as a floating block: no|}}{{#if:yes| Rendered inline: yes|}} |
... text text text
[[File:example.jpg{{#if:frameless||frameless}}{{#if:||{{{2}}}}}{{#if:|{{#ifeq:|none|||}}||caption}}]]
text text text ...
| wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text |
| frameless and border|frameless}}{{#if:no| Rendered as a floating block: no|}}{{#if:yes| Rendered inline: yes|}} |
... text text text
[[File:example.jpg{{#if:frameless||frameless}}{{#if:border||border}}{{#if:|{{#ifeq:|none|||}}||caption}}]]
text text text ...
| wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text |
| frame|frame}}{{#if:yes| Rendered as a floating block: yes|}}{{#if:no| Rendered inline: no|}} |
... text text text
[[File:example.jpg{{#if:frame||frame}}{{#if:||{{{2}}}}}{{#if:|{{#ifeq:|none|||}}||caption}}]]
text text text ...
| wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text |
| thumb or thumbnail|thumb}}{{#if:yes| Rendered as a floating block: yes|}}{{#if:no| Rendered inline: no|}} |
... text text text
[[File:example.jpg{{#if:thumb||thumb}}{{#if:||{{{2}}}}}{{#if:|{{#ifeq:|none|||}}||caption}}]]
text text text ...
| wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text |
When the height of an image in thumbnail is bigger than its width (i.e. in portrait orientation rather than lansdscape) and you find it too outstanding, you may try the option upright, which will try to adjust its size to more desirable size by reducing the height instead the width. The alternative is to specify the desired maximum height (in pixels) explicitly.
Note that by writing thumb={filename}, you can use a different image for the thumbnail.
Among different formats, the effect of the size parameter may be different, as shown below.
bordered, the size can be both reduced and enlarged to any specified size.
frame always ignores the size specification, the original image will be reduced if it exceeds the maximum size defined in user preferences.
thumb and frameless can be reduced, but can not be enlarged beyond the original size of the image.
| Format | Reduced | Enlarged | |
|---|---|---|---|
| {{#if: | (not specified) }} |
[[File:Example.jpg|{{#if: ||}}50px]]
|
[[File:Example.jpg|{{#if: ||}}500px]]
|
| border|(not specified) }} |
[[File:Example.jpg|{{#if: border |border|}}50px]]
|
[[File:Example.jpg|{{#if: border |border|}}500px]]
| |
| frame|(not specified) }} |
[[File:Example.jpg|{{#if: frame |frame|}}50px]]
|
[[File:Example.jpg|{{#if: frame |frame|}}500px]]
| |
| thumb|(not specified) }} |
[[File:Example.jpg|{{#if: thumb |thumb|}}50px]]
|
[[File:Example.jpg|{{#if: thumb |thumb|}}500px]]
| |
| frameless|(not specified) }} |
[[File:Example.jpg|{{#if: frameless |frameless|}}50px]]
|
[[File:Example.jpg|{{#if: frameless |frameless|}}500px]]
|
Note that when using the frame or thumb[nail] formats, the default horizontal alignment will be right.
| Description | You type | You get |
|---|---|---|
| no horizontal alignment specified, or default alignment|}}{{#if:no| Rendered as a floating block: no|}}{{#if:yes| Rendered inline: yes|}} |
... text text text
[[File:example.jpg{{#if:||'}}{{#if:100px||'100px}}{{#if:|{{#ifeq:|none|||}}||caption}}]]
text text text ...
| wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text |
| specify horizontal alignment as: none|none}}{{#if:no| Rendered as a floating block: no|}}{{#if:no| Rendered inline: no|}} |
... text text text
[[File:example.jpg{{#if:none||none}}{{#if:100px||100px}}{{#if:|{{#ifeq:|none|||}}||caption}}]]
text text text ...
| wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text |
| specify horizontal alignment as: center|center}}{{#if:no| Rendered as a floating block: no|}}{{#if:no| Rendered inline: no|}} |
... text text text
[[File:example.jpg{{#if:center||center}}{{#if:100px||100px}}{{#if:|{{#ifeq:|none|||}}||caption}}]]
text text text ...
| wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text |
| specify horizontal alignment as: left|left}}{{#if:yes| Rendered as a floating block: yes|}}{{#if:no| Rendered inline: no|}} |
... text text text
[[File:example.jpg{{#if:left||left}}{{#if:100px||100px}}{{#if:|{{#ifeq:|none|||}}||caption}}]]
text text text ...
| wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text |
| specify horizontal alignment as: right|right}}{{#if:yes| Rendered as a floating block: yes|}}{{#if:no| Rendered inline: no|}} |
... text text text
[[File:example.jpg{{#if:right||right}}{{#if:100px||100px}}{{#if:|{{#ifeq:|none|||}}||caption}}]]
text text text ...
| wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text |
The vertical alignment options take effect only if the image is rendered as an inline element and is not floating. They alter the way the inlined image will be vertically aligned with the text present in the same block before and/or after this image on the same rendered row.
Note that the rendered line of text where inline images are inserted (and the lines of text rendered after the current one) may be moved down (this will increase the line-height conditionally by additional line spacing, just as it may occur with spans of text with variable font sizes, or with superscripts and subscripts) to allow the image height to be fully displayed with this alignment constraint.
<p style="border:1px solid #AAA;background:#FF0;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|40px|border|top]] <del>text</del></u></span></p> <p style="border:1px solid #AAA;background:#FF0;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|40px|border|text-top]] <del>text</del></u></span></p> <p style="border:1px solid #AAA;background:#FF0;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|40px|border|super]] <del>text</del></u></span></p> <p style="border:1px solid #AAA;background:#FF0;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|40px|border|baseline]] <del>text</del></u></span></p> <p style="border:1px solid #AAA;background:#FF0;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|40px|border|sub]] <del>text</del></u></span></p> <p style="border:1px solid #AAA;background:#FF0;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|40px|border]] <del>text</del></u></span></p> <p style="border:1px solid #AAA;background:#FF0;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|40px|border|middle]] <del>text</del></u></span></p> <p style="border:1px solid #AAA;background:#FF0;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|40px|border|text-bottom]] <del>text</del></u></span></p> <p style="border:1px solid #AAA;background:#FF0;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|40px|border|bottom]] <del>text</del></u></span></p>
results in the following (to show the alignment result more clearly, the text spans are overlined and underlined, the line-height is increased to 200% of the font-height, the font-height is emphasized with a yellow background covering the line margins, and the full line-height is shown with a dark gray border; additionally images of different sizes are aligned, including one with an additional border that adds some pixels to its specified dimensions and slightly changes its vertical alignment):
Notes:
On occasion it is desirable to stop text (or other inline non-floating images) from flowing around a floating image. Depending on the web browser's screen resolution and such, text flow on the right side of an image may cause a section header (for instance, == My Header ==) to appear to the right of the image, instead of below it, as a user may expect. The text flow can be stopped by placing <br style="clear: both" /> before the text that should start below the floatting image.
All images rendered as blocks (including non-floating centered images, left- or right-floating images, as well as framed or thumbnailed floating images) are implicitly breaking the surrounding lines of text (terminating the current block of text before the image, and creating a new paragraph for the text after them). They will then stack vertically along their left or right alignment margin (or along the center line between these margins for centered images).
The following table shows how to alter the link target (whose default is the image description page) or how to remove it. Changing the link does not alter the format described in the previous sections.
| Description | You type | You get |
|---|---|---|
| internal link|}}{{#if:| Rendered as a floating block: |}}{{#if:| Rendered inline: |}} |
... text text text
[[File:example.jpg{{#if:||{{{frame}}}}}{{#if:link=Main Page||link=Main Page}}{{#if:|{{#ifeq:|none|||}}||caption}}]]
text text text ...
| wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text |
| external link|}}{{#if:| Rendered as a floating block: |}}{{#if:| Rendered inline: |}} |
... text text text
[[File:example.jpg{{#if:||{{{frame}}}}}{{#if:link=http://wikipedia.org||link=http://wikipedia.org}}{{#if:|{{#ifeq:|none|||}}||caption}}]]
text text text ...
| wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text |
| no link (external or file page)|}}{{#if:| Rendered as a floating block: |}}{{#if:| Rendered inline: |}} |
... text text text
[[File:example.jpg{{#if:||{{{frame}}}}}{{#if:link=||link=}}{{#if:|{{#ifeq:|none|||}}||caption}}]]
text text text ...
| wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
text text text text text text text text text text text text text text text text text text text text text text text text text ![]() text text text text text text text text text text text text text text text text text text text text text text text text text |
Warning :
It's easy to make a gallery of thumbnails only, not other images, with the <gallery> tag. The syntax is:
<gallery>
Image:file_name.ext|caption
Image:file_name.ext|caption
{...}
</gallery>
Note that the image code is not enclosed in brackets when enclosed in gallery tags.
Captions are optional, and may contain wiki links or other formatting.
for example:
<gallery>
File:Example.jpg|Item 1
File:Example.jpg|a link to [[Help:Contents]]
File:Example.jpg
File:Example.jpg
File:Example.jpg| ''italic caption''
File:Example.jpg|on page "{{PAGENAME}}"
</gallery>
is formatted as:
a link to Help:Contents |
|||
The gallery tag itself takes several additional parameters, specified as attribute name-value pairs:
<gallery {parameters}>
{images}
</gallery>
caption={caption}: sets a caption on the gallery.
widths={width}px: sets the widths of the images, default 120px. Note the plural, widths
heights={heights}px: sets the (max) heights of the images.
perrow={integer}: sets the number of images per row.
Example:
Coding:
<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>
Result:
If you put a colon (:) before File:, the image will not be embedded and the link will lead to the description page of the file.
[[:File:Example.jpg]] [[:File:Example.jpg|Sunflowers]]
results in
This will make a 50px width picture with a link to the page MediaWiki:
[[File:Wiki.png|50px|link=MediaWiki]]
You can use the pseudo-namespace “Media” to link directly to a file without rendering it, bypassing the description page.
[[Media:Example.jpg]] [[Media:Example.jpg|Sunflowers]]
results in
You can also use:
[[Special:FilePath/Example.jpg]]
which can be used to link to a potential file, even if it doesn't exist. You can also use:
{{FILEPATH:Example.jpg}}
which generates an external URL to the file inline: http://wiki.meego.com/images/Example.jpg
Before using images in your page, the system administrator of your wiki must have enabled file uploads and a user has to upload the file. System administrators may also set the wiki to accept files from foreign repositories, such as the Wikimedia Commons. For server side image resizing it is necessary to have a scaler configured (such as GD2, ImageMagick, etc.).
You can link to an external file available online using the same syntax used for linking to an external web page. With these syntaxes, the image will not be rendered, but only the text of the link to this image will be displayed.
[http://url.for/some/image.png]
Or with a different displayed text:
[http://url.for/some/image.png link text here]
Additional MediaWiki markup or HTML/CSS formatting (for inline elements) is permitted in this displayed text (with the exception of embedded links that would break the surrounding link):
[http://www.example.com/some/image.png Example '''<del>rich</del>''' ''<ins>link text</ins>'' here.]
which renders as: Example rich link text<ins> here.
If it is enabled on your wiki (see Manual:$wgAllowExternalImages), you can also embed external images. To do that, simply insert the image's url:
http://url.for/some/image.png
Currently, embedded images cannot be resized, but they may be formatted by surrounding MediaWiki markup or HTML/CSS code.
If this wiki option is not enabled, the image will not be embedded but rendered as a textual link to the external site, just like above.