Contents

Adding a Picture to a UBC Wiki Page using wikitext

Embedding an Image Hosted on Wikimedia Commons

If an image is hosted on Wikimedia Commons, it is very easy to embed an image.

Formatting Example of Wiki Code to Use Display
Just add the filename to the wiki page Image from https://commons.wikimedia.org/wiki/Main_Page#/media/File:Nymphenburger_Schloss_at_sunset.JPG will be formatted as [[File:Nymphenburger_Schloss_at_sunset.JPG]] For example, Nymphenburger Schloss at sunset.JPG
adding attributes to the image Similarly to an image uploaded in ubcwiki, you can add attributes directly to the image [[File:Nymphenburger_Schloss_at_sunset.jpg|100px]] For example, Nymphenburger Schloss at sunset.JPG

External image syntax

You can embed an "external" image by simply typing the full URL of the image. For example:

https://open.ubc.ca/files/2019/09/openubc.jpg

will display the image on screen.

openubc.jpg

Internal image syntax

After uploading the image, create a link to the image file to embed it on a page. Thus, for the below example, type in the following code into the wiki edit page of the article in which you want the image to be embedded.

Formatting Example of Wiki Code to Use Display
Adding an image [[Image:COI_model_adapted.jpg‎]] COI model adapted.jpg.

Adding Images via Wikimedia Commons

Formatting Example of Wiki Code to Use Display
Adding an image [[File:Bison bonasus bonasus.jpg|Bison bonasus bonasus]] Bison bonasus bonasus

Image Options

In addition to embedding an image, you can also give it alternative text, a frame, or make it centered. There are many different options for how images are displayed. The full syntax for displaying an image is:

[[File:file name.extension|options|caption]]

Choose to have none or multiple options from the list below:

These options control how the image is formatted and embedded in the rest of the page. Each option should be separated by pipes (|).

Examples

Formatting Example of Wiki Code to use Display
Regular Image with a caption [[File:File:ExampleImage.jpg|Caption text that shows in mouse over and if image does not load.]] Caption text that shows in mouse over and if image does not load.
Image with Frame [[File:ExampleImage.jpg|frame|Caption: This is an example image]]
Caption: This is an example image
Thumbnail Image [[File:ExampleImage.jpg|thumb|CCaption: This is an example image]]
Caption: This is an example image

Additional Image Display Options

Resizing option

Change the size of the image using the following parameters:

Note that the image will always retain its aspect ratio, and can only be reduced in size if it's not in a scalable media type such as SVG (bitmap images cannot be scaled up). The default maximum size depends on the format and the internal image dimensions (according to its media type).

Examples:

Width Option Code to Use Example Image
Image 50 pixels wide [[File:ExampleImage.jpg|50px|This is the caption]] This is the caption
Image 100 pixels wide [[File:ExampleImage.jpg|100px|This is the caption]] This is the caption
Image 200 pixels tall [[File:ExampleImage.jpg|x200px|This is the caption]] This is the caption

Size and Frame

Horizontal alignment option

one of left, right, center, none; This controls the horizontal alignment (and inline/block or floating styles) of the image within a text (no default value).

Examples:

Format Option Code to Use Example Image
Left Aligned Image (sized to be 50 pixels wide) [[File:ExampleImage.jpg|50px|left|This is the caption]]
This is the caption
Right Alight Image (sized to be 50 pixels) [[File:ExampleImage.jpg|50px|right|This is the caption]]
This is the caption

Vertical alignment option

one of baseline, sub, super, top, text-top, middle, bottom, text-bottom; ThisControls the vertical alignment of a non-floatting inline image with the text before or after the image, and in the same block (the default vertical alignment is middle).


Examples:

Format Option Code to Use Example Image
Top Aligned Image (sized to be 100 pixels wide) [[File:ExampleImage.jpg|100px|top|This is the caption]] Here is some textThis is the captionHere is some text
Bottom Alight Image (sized to be 100 pixels) [[File:ExampleImage.jpg|100px|bottom|This is the caption]] Here is some text This is the caption Here is some text

Link option

Note that the link option cannot be used in conjunction with thumb or thumbnail, as thumb is always meant to link to the larger version of the image. In addition, link cannot be used with frame.

Other specific options:


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:ExampleImage.jpg|20px|<span title=""></span>]] renders as

Embedding an Image Hosted on Another Website

If an image is hosted on another website, it can also be displayed on the UBC Wiki:

Formatting Example of Wiki Code to Use Display
Just add the image URL to the wiki page http://farm4.static.flickr.com/3220/2882594321_bdaf3dcb3b.jpg For example, 2882594321_bdaf3dcb3b.jpg.
To provide attribution for a photo (for instance if it is a Creative Commons Licensed work on Flickr), upload the photo and put it in a frame with attribution [[Image:Pinnochio in Urbino.jpg|center|frame|Uploaded to Flickr by [http://www.flickr.com/photos/38795936@N00/2882594321/sizes/m/ Sparklefish]]]
Uploaded to Flickr by Sparklefish


Direct Text Link to a Uploaded File

Instead of displaying a file on a wiki page, it's also possible to create a text link directly to the file itself. There are two options when linking to an uploaded file.

Formatting Wiki Code Display
Direct Link to Uploaded File [[Media:file-name.ext]]. For example, [[Media:Filelink-button.png]]. For example, Media:Filelink-button.png.
Link to the Wiki's Uploaded File [[:File:Filelink-button.png]]. File:Filelink-button.png.