Help:Images

From Karnataka Open Educational Resources
Jump to navigation Jump to search

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 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).
  • .tiff : Tagged image format. Often used for high-resolution archival photographs. Often used with the extension:PagedTiffHandler.
  • .ogg, .oga, .ogv : Ogg multimedia (audio or video) Not an image format, but treated similarly. Often used with extension:OggHandler.
  • .pdf : multipaged documents in the Portable Document Format (initially specified by Adobe). Often used in conjunction with extension:PdfHandler
    Only a single page of a .pdf or .djvu file is shown at one time.

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]] will link the image to wikipedia.org, or [[File:Example.jpg|20px|link=MediaWiki]] will link to mediawiki
      • ! If you set |link=| (empty), then no title will be rendered.

If a parameter does not match any of the other possibilities, it is assumed to be the caption text. Caption text only shows below the image in thumb and frame formats. 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.

Rendering a gallery of images

Picasa Gallery syntax

{{ #widget:Picasa |user=itfc.communications@gmail.com |album=5917904534857685313 |width=300 |height=200 |captions=1 |autoplay=1 |interval=5 }}

Gallery syntax

It's easy to make a gallery of thumbnails with the <gallery> tag. The syntax is:

<gallery>
File:file_name.ext|caption|alt=alt language
File:file_name.ext|caption|alt=alt language
{...}
</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.

If an image is in the File namespace, the File: prefix can be omitted.

Files at other websites

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 here.

If it is enabled on your wiki, 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.