Help:Images
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).
Supported media types for images
The following file formats are supported by Mediawiki by default:
- .jpg or .jpeg : bitmap image compressed in the standard JPEG format (this lossy format is most suitable for photographs).
- .png : bitmap image in the Portable Network Graphics format (specified by the W3 Consortium).
- .gif : bitmap image in the legacy Graphics Interchange Format.
Other formats used on Wikimedia, and commonly enabled elsewhere (these may require extra set-up beyond what is enabled by default):
- .svg : scalable image in the Scalable Vector Graphics format (specified by the W3 Consortium). See Template:Mediawiki.
- .tiff : Tagged image format. Often used for high-resolution archival photographs. Often used with Template:Mediawiki.
- .ogg, .oga, .ogv : Ogg multimedia (audio or video) Not an image format, but treated similarly. Often used with Template:Mediawiki
- .pdf : multipaged documents in the Portable Document Format (initially specified by Adobe). Often used in conjunction with Template:Mediawiki
- .djvu : multipaged bitmap documents in the DejaVu format (most often, scans of books). See Template:Mediawiki
- Only a single page of a .pdf or .djvu file is shown at one time.
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.
Rendering a single image
Syntax
The full syntax for displaying an image is:
[[File:filename.extension|options|caption]]
where options can be zero or more of the following, separated by pipes (|):
- Format option: one of border and/or frameless, frame, thumb (or thumbnail);
- Controls how the rendered image is formatted and embedded in the rest of the page.
- Resizing option: one of
- {width}px — Resizes the image to fit within the given maximum width in pixels, without restricting its height;
- x{height}px — Resizes the image to fit within the given maximum height in pixels, without restricting its width;
- {width}x{height}px — Resizes the image to fit within the given width and height in pixels;
- upright — Resizes an image to fit within reasonable dimensions, according to user preferences (suitable for images whose height is larger than width).
- Note that the image will always retain its aspect ratio, and can only be reduced (not increased) in size unless it's in a scalable media type (bitmap images cannot be scaled up).
- The default maximum size depends on the format and the internal image dimensions (according to its media type).
- Horizontal alignment option: one of left, right, center, none;
- Controls the horizontal alignment (and inline/block or floating styles) of the image within a text (no default value).
- Vertical alignment option: one of baseline, sub, super, top, text-top, middle, bottom, text-bottom;
- Controls the vertical alignment of a non-floating inline image with the text before or after the image, and in the same block (the default vertical alignment is middle).
- Link option: one of
- link={target} — Allows to change the target (to an arbitrary page title, or URL) of the generated link, activable on the rendered image surface; e.g.
[[File:Example.jpg|20px|link=http://www.wikipedia.org]]
renders as 20px (external link), or[[File:Example.jpg|20px|link=MediaWiki]]
renders as 20px (internal link). - link= (with an empty value) — (Template:Mediawiki) Displays an image without any activable link; e.g.
[[File:Example.jpg|20px|link=]]
renders as 20px.
- link={target} — Allows to change the target (to an arbitrary page title, or URL) of the generated link, activable on the rendered image surface; e.g.
- ! Link does not work with thumb, thumbnail or frame.
- Other specific options:
- alt={alternative text} — (Template:Mediawiki) Defines the alternative text (maps to the HTML attribute
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). - page={number} — Renders the specified page number (currently only applicable when showing a .djvu or .pdf file).
- alt={alternative text} — (Template:Mediawiki) Defines the alternative text (maps to the HTML attribute
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 File:Example.jpg.