User:Magill/Editing - Image syntax

Jump to navigation Jump to search

text from Help:Images

Capture text for ex 1
Description for ex 2

Description: border for ex 3
Description: frameless for ex 4
Description: frame for ex 5
Description: thumb for ex 6

Examples: Syntax for displaying Images

Our templates take care of mandatory images, such as item icons, NPC images, location articles, etc. You just need to provide the image as such.

However, sometimes you want to add to a gallery, illustrate something with an image rather than words, etc. Then you may use any of the following formats. However, embedding remote images is disallowed and prohibited; you may add a link for them though.

Example 1: [[File:Arador's End Outpost.jpg|thumb|250px|right|Capture text for x 1]]

Notice the frame and capture text. This is from the thumb part of the syntax.

Example 2: [[File:Arador's End Outpost.jpg|250px|right|Description for x 2]]

This is the same image without the thumb.

To include a file in a page, use a link in one of the following forms:

  • [[File:Somefile.jpg]]
    for the full size version - this should usually never be used
  • [[File:Somefile.jpg|250px|thumb|left|Capture text]]
    for a 250 pixel wide rendition in a frame to the left with 'Capture text' as its capture.
  • [[File:Somefile.jpg|250px|left|Description text]]
    for a plain 250 pixel wide rendition with 'Description text' as its alternative text.
  • [[Media:Somefile.ogg]] for just creating a link to a file.

Notice that several boilerplates state their preferred way of displaying extra images, see for example Landmarks, under "Gallery". Please accept our wish for conformity.

Text from MediaWiki Help:Images


The full syntax for displaying an image is:


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=]] renders as File:Example.jpg|20px|link= (external link), or [[File:Example.jpg|20px|link=MediaWiki]] renders as File:Example.jpg|20px|link=MediaWiki (internal link).
    • link= (with an empty value) — {mediawiki|rev:41727|MediaWiki 1.14+) Displays an image without any activable link; e.g. [[File:Example.jpg|20px|link=]] renders as File:Example.jpg|20px|link=</>.
      • ! If you set |link=| (empty), then no title will be rendered. (See bugzilla:21454.)
  • Other specific options:
    • alt={alternative text}{mediawiki|rev:41837|MediaWiki 1.14+) Defines the alternative text (maps to the HTML attribute alt="..." of the generated <img /> 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).
    • class={html class} — (MediaWiki 1.20+) Defines classes (maps to the HTML attribute class="..." of the generated <img /> element).
    • lang={language code} — (MediaWiki 1.22+) For SVG files containing <switch> statements varying on a systemLanguage attribute, selects what language to render the file in. The default is always English, even on non-English wikis.

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 tooltip text in any other format. Caption text displayed in the thumb and frame formats may contain wiki links and other formatting. MediaWiki extensions can add additional options.

If 'alt' is not specified and a caption is provided, the alternative text will be created automatically from the caption, stripped of formatting.