Open main menu
MediaWiki使用手冊: 目錄 · 讀者手冊 · 編輯手冊 · 仲裁員手冊 · 系統管理員手冊 +/-


檔案上傳後,系統會自動創建一個該檔案的說明頁,頁面名稱包含檔案名(含副檔名)和「File:」前綴(或通常是 {{ns:File}} (MediaWiki 1.14 以上)、{{ns:Image}} (MediaWiki 1.13 或更早)變數的值)。


維基媒體有一個「專門用於上傳檔案」的維基項目,上傳的檔案可用於其他維基項目,這個項目就是維基共享資源(僅限自由版權內容,無『正當使用(Fair use)』內容)。上傳於維基共享資源的圖片可以被所有維基計劃使用。而上傳到其他維基的檔案不能用於其他計劃,且在該計劃上無法使用維基共享資源上的同名檔案。所以若無特殊理由(例如:以局部版本取代維基共享資源上之圖 ,而不更改連結),請將自由版權內容上傳到維基共享資源。









上傳一個與現有檔案同名的檔案,舊檔將被取代。當一個檔案被取代時(例如條目中的圖片被取代),這個變更不會在條目歷史中記錄下來,也不會在條目的相關更改中顯示,亦不會在圖片描述頁的歷史中記錄(除非描述也被同時更改)。但是,這會在圖片描述頁的「歷史版本」中被記錄,並且m:Upload log中會留下記錄。因此,欲查看條目中的圖片、檔案變更歷史,應當查看檔案描述頁(MediaWiki 1.13之後的版本)。

Special:Imagelist provides the same information as the Upload log, but it uses the user's local time instead of the default time (set to Coordinated Universal Time for Wikimedia projects). In addition it gives the file sizes. Further it allows loading of portions and sorting by size in addition to sorting by date, and it has not only links to the image description pages, but also directly to the images.


取代或刪除維基共享資源上的檔案時,所有使用該檔案的維基計劃都會受到影響。所以必須連結維基共享上之檔案頁至各維基子計劃內之相同檔案。縱使這些檔案未被「正式製造」(created explicitly)而無可編輯之內容,「Image links」一節仍顯示各子計劃內有用此檔之頁。



上傳前,請先為檔案取個適當的名字,檔案一旦上傳就無法更名,所以請慬慎取檔案名。各空格、破折號、括號、大小寫都應符合習慣。好的檔案名應該是有描述性的,例如File:Rotating earth.gif,請不要使用類似DSC_4432.jpg的檔案名。檔名雖不會出現於插使用該檔案的頁面,但見於包含此檔案之分類(category)等地方。





 * This is the list of preferred extensions for uploading files. Uploading files
 * with extensions not in this list will trigger a warning.
$wgFileExtensions = array( 'png', 'gif', 'jpg', 'jpeg', 'doc', 'docx', 'xls', 'xlsx', 'pdf' );

/** Files with these extensions will never be allowed as uploads. */
$wgFileBlacklist = array(
    # HTML may contain cookie-stealing JavaScript and web bugs
    'html', 'htm', 'js', 'jsb', 'mhtml', 'mht',
    # PHP scripts may execute arbitrary code on the server
    'php', 'phtml', 'php3', 'php4', 'php5', 'phps',
    # Other types that may be interpreted by some servers
    'shtml', 'jhtml', 'pl', 'py', 'cgi',
    # May contain harmful executables for Windows victims
    'exe', 'scr', 'dll', 'msi', 'vbs', 'bat', 'com', 'pif', 'cmd', 'vxd', 'cpl' );

/** Files with these mime types will never be allowed as uploads
 * if $wgVerifyMimeType is enabled.
$wgMimeTypeBlacklist= array(
    # HTML may contain cookie-stealing JavaScript and web bugs
    'text/html', 'text/javascript', 'text/x-javascript',  'application/x-shellscript',
    # PHP scripts may execute arbitrary code on the server
    'application/x-php', 'text/x-php',
    # Other types that may be interpreted by some servers
    'text/x-python', 'text/x-perl', 'text/x-bash', 'text/x-sh', 'text/x-csh',
    # Windows metafile, client-side vulnerability on some systems

/** This is a flag to determine whether or not to check file extensions on upload. */
$wgCheckFileExtensions = false;

 * If this is turned off, users may override the warning for files not covered
 * by $wgFileExtensions.
$wgStrictFileExtensions = true;

/** Warn if uploaded files are larger than this (in bytes), or false to disable*/
$wgUploadSizeWarning = false;


關於SVG圖像,見SVG image support

關於視訊,見Video policy

There may be a size limit, the largest one on en: is 6.5 megabytes (but please be reasonable).

The most common type of media apart from images is:

  • sound -- preferred format: Ogg Vorbis.

If you want to upload file types other than .jpg or .ogg, e.g., .pdf, in newer versions of mediawiki, you have to modify the file LocalSettings.php by copying the variable and its contents from DefaultSettings.php. Afterward, you can edit it accordingly: $wgFileExtensions = array( 'png', 'jpg', 'jpeg', 'ogg','doc','xls','ppt','mp3','sxc','pdf' );

You may also need to remove this extension from the filetype blacklist (in /includes/DefaultSettings.php).



By default, MediaWiki only allows you to upload certain types of files (extensions gif, jpg, jpeg, ogg and png). This is managed by this order in includes/DefaultSettings.php:

$wgFileExtensions = array( 'png', 'gif', 'jpg', 'jpeg', 'ogg' );

If you want to be able to upload other file types, for instance ZIP files you must add this line to LocalSettings.php:

$wgFileExtensions = array( 'png', 'gif', 'jpg', 'jpeg', 'ogg', 'zip');

Caution: do not modify the line in DefaultSettings.php because it will break when updating

Also you may find php and apache limit the filesize of uploads too giving spurious messages on the upload page such as "The file you uploaded seems to be empty. This might be due to a typo in the file name. Please check whether you really want to upload this file." See Q: What affects the maximum file size which can be uploaded? on this page for details: (It might be better to have this information conglomerated more centrally).

Take in account there is a blacklist of file extensions in includes/DefaultSettings.php:

$wgFileBlacklist = array(
# HTML may contain cookie-stealing JavaScript and web bugs
'html', 'htm',
# PHP scripts may execute arbitrary code on the server
'php', 'phtml', 'php3', 'php4', 'phps',
# Other types that may be interpreted by some servers
'shtml', 'jhtml', 'pl', 'py',
# May contain harmful executables for Windows victims
'exe', 'scr', 'dll', 'msi', 'vbs', 'bat', 'com', 'pif', 'cmd', 'vxd', 'cpl' );

Apache has a directive "LimitRequestBody", which controls the maximum number of bytes allowed in ANY http request.


要想使檔案與其相應的圖示一起被放在鏈接處,同時也有檔案的維基頁面鏈接, 參見這裡.





直接連結到檔案位址請用[[Media:檔案名]],例如:Media:tst.png。若要連結至圖之解釋頁,請用 [[:Image:檔案名]],效果:Image:tst.png(首冒號不會顯示)。使用[[Image:tst.png]]會直接顯示圖片,效果: 









此「內部」指計劃內或維基共享上。An image name is assumed to refer to the one in the same project if it exists there, otherwise to one on Commons. If neither exists a link to the upload page appears, with class="new" ("red link"). The link is rendered the same as one to the edit page of the non-existing image page, except that the former shows the canonical form of the pagename.

Only images proper can be automatically presented, sound is not automatically played.

An embedded internal image automatically links to the image page, which shows the full image, or, depending on preferences, a reduced version with a link to the full version. The page also provides info about the image.

[[image:tst.png|abc]] gives  

[[image:tst.png|50px|abc]] gives  

The form [[image:tst.png|50px|thumb|abc]] does not allow enlargement, it gives (see on the right):


To add the uploaded image to an article as a thumbnail, one can use [[Image: image name including extension |thumb|caption]] or [[Image: image name including extension |thumb|width in pixels px|caption]].

The default thumbnail width can be set in the preferences, so typically it is better not to specify "px", in order to respect the users' preferences (unless, for a special reason, a specific size is required regardless of preferences, or a size is specified outside the range of widths 120-300 that can be set in the preferences).

The caption can contain links. Both the image itself and an icon link to the image page. The icon has the link title "Enlarge" in its hoverbox, even in cases where the image on the image page is smaller. Depending on preferences the image on the image page may be smaller than the thumbnail image, so a link may be convenient from the thumbnail straight to the image in actual size. E.g. [[image:tst.png|thumb|50px|[[Media:tst.png|actual size]]]]

Middle East; for more detailed pdf-version see [1]

欲知更多選擇,見en:Wikipedia:Extended image syntax. Also, the source of existing pages with images are useful as examples.


[[image:tst.png|left|thumb|50px|[[help:contents|demo]]]] puts the image at the left; text that follows floats to the right of it; if a second image immediately comes after the first, the second abuts to the right side of the first; if there is text in between then the second image is at the lower right of the first, under this text:

Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. between the 3rd and 4th images.

Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. after the 4th image.

With [[image:tst.png|none|thumb|50px|[[help:contents|demo]]]] the image is put at the left, and text that follows starts below it.

Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent lupta


[[image:tst.png|right|thumb|50px|[[help:contents|demo]]]] puts the image at the right; text that follows floats to the left of it. The situation is not symmetric with the case above: a second image is put at the extreme right again, under the first.

zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. after the 1st image.

after the 2nd image.

Using full width againEdit

Use <br clear="all" />, or on projects that have Template:Clr (Meta and en:): {{clr}}. Text floats around the image until it gets to {{clr}} (in Meta) like this.

After {{clr}}, however, text can float no longer, and restarts from under the image, using the full width again like this,...... like this, like this, like this, like this, like this, like this, like this.


Inline images cannot have a caption, but they can have a "title"-attribute (often misidentified as the "alt" attribute, which has a different purpose), which is shown in the hoverbox (in the cases above, for the image it is the same as the caption, and for the enlarge icon it is "Enlarge"). It is the last item of the image code, hence, if there is only the image name with prefix "image:" it gives that; if there is an empty item by ending with a pipe character ("|") it gives none; otherwise, it gives the image code item that happens to be last, unless a proper text is specified.

The size of the images can be reduced but they can not be enlarged.

Example (note the hoverbox too): "text [[File:Wikipedia icon size logo.gif]] text [[File:Wikipedia icon size logo.gif|5px|]] text [[File:Wikipedia icon size logo.gif|100px|demo]] text" gives "text   text   text   text".


Below one can see the result of the three types of internal link style and external link style on this project. To test this in another project, copy the wikitext there. If applicable, check also the interlanguage links at the margin of the page. Note that some links go to the image description page, others just to the image itself.

  • [[Image:Tile Hill train 550.jpg]]


  • [[:Image:Tile Hill train 550.jpg]]

Image:Tile Hill train 550.jpg

  • [[Media:Tile Hill train 550.jpg]]

Media:Tile Hill train 550.jpg

  • external, with label: [ train]


  • external, footnote style: []


Gallery tag, category, table of imagesEdit

The gallery-tag is a quick way to show thumbnails in four columns. Each entry is of the form "Image:image name or "Image:image name|caption, possibly with links". It also allows text taking the position of an image, but not with links: if a text entry contains a link, the whole entry is ignored; an image tag with square brackets is also ignored. It is possible to give a title to the gallery with the caption parameter.

<gallery caption="Sample gallery">
Image:Drenthe-Position.png|[[w:Drenthe|Drenthe]], the least crowded province
[[Friesland]] is beautiful
Image:Zuid_Holland-Position.png|[[w:South Holland|South Holland]], the most crowded province


Note that, with the gallery tag, the images have a single fixed width.

Depending on the browser, a long caption may or may not widen a whole column of images:

  • even if it does, if necessary to fit the four columns on the screen, captions wrap automatically
  • alternatively, a long caption makes the whole row taller, because too long captions wrap to produce multiple lines in their container. See also w:Wikipedia:Gallery.

A gallery of images in a category is automatically shown as the fourth section of the category page. The first 20 characters of the image name are shown, with dots if that is not the full name. Both the image and the name link to the image page. No alternative text or other links are possible. Also the file size is shown.

For a comparison, see commons:Category:William-Adolphe Bouguereau.

Using table syntax, with images in separate cells, and the image syntax explained elsewhere on this page, gives more control over size, layout, captions, etc. than each of these two methods. However, only a category automatically gives file sizes.

Example of an image table:

|+'''Provinces of the Netherlands'''
| valign="top"|
[[Image:Drenthe-Position.png|thumb|left|150px|[[w:Drenthe|]], the least crowded province]]
| valign="top"|
| valign="top"|
| valign="top"|
| valign="top"|
[[Image:Zuid_Holland-Position.png|thumb|left|100px|[[w:South Holland|]], the most crowded province]]
| valign="top"|


Provinces of the Netherlands
Drenthe, the least crowded province
South Holland, the most crowded province

Note that, with this method, each image has a width specified by the size option, if any, and a height depending on whether there is caption or not, and how long the caption is. The width of a column is determined by the widest image in it, and the height of the row is determined by the tallest image in it.


Navigational maps like [3] have map areas linked to pages. The html with <area> tags can not be put in the wikitext. However, there are the following possibilities:

  • EasyTimeline allows the creation of an image and a page embedding that image, with rectangular map areas defined by <area> tags in the html. The title of a link to a non-internal page is only the domain name, e.g. "". The length and width of the rectangle can not be controlled, except that it depends on the length of the link label and its font size. In case of overlap of rectangles one has to look at the hoverbox or statusbar to avoid following the wrong link. In case of much overlap it may not be possible to use all links.
  • One can divide an image in rectangles, like in these chess and go positions, or superimpose an area with images (see above) and link each rectangle/image to the desired target by means of a redirect on the image page (provided that the target is internal).

See also:

EasyTimeline 例Edit

例 1

ImageSize  = width:400 height:150
PlotArea   = width:400 height:150 left:0 bottom:0
TimeAxis  = orientation:vertical # dummy, required
Period    = from:0 till:1 # dummy, required
Define $s = fontsize:XL
TextData  =
  pos:(50,120) $s text:[|o Leiden]
  pos:(150,110) $s text:[|o Alphen aan den Rijn]
  pos:(10,80) $s text:[|o The Hague]
  pos:(50,40) $s text:[|o Rotterdam]



例 2

Preset     = TimeHorizontal_AutoPlaceBars_UnitYear
ImageSize = width:500 barincrement:50
Period     = from:0 till:12
Define $s = fontsize:XL
BackgroundColors = canvas:white
  bar:a from:3 till:4 $s text:[|Leiden]
  bar:a  from:6 till:7 $s text:[|Alphen aan den Rijn]
  bar:b  from:1 till:2 $s text:[|The Hague]
  bar:c  from:3 till:4 $s text:[|Rotterdam]




Some attempts for other alternatives (note the hover boxes):


Ascii art map, with both the city outline and the label clickable:

   xxx Leiden

xxxx The Hague

       xxxxx Rotterdam

When external images can be embedded:

The html titles are "w: Leiden", etc., the alt attribute is "Tst.png". Opera shows the title in the hoverbox, and also the url, IE only shows the titles.

With labels: Leiden The Hague Rotterdam

See also m:Maps, m:Maps' clickability.


Images on MediaWiki:Bad image list can not be embedded, they appear as regular link to the image page. See e.g. w:en:MediaWiki:Bad image list.

Protection of an image page is automatically also protection of the image itself: i.e. a new image under the name of the existing image can only be uploaded by a sysop.




$wgAllowExternalImages = true;



必要時,从一个企劃中下載圖片然後上傳至維基共享資源(假如該圖像是自由版權的並且不屬於合理使用(fair use)),該圖片將可以在所有企劃中使用。



If enabled, use unbracketed external link style, i.e. just the URL (of the image itself, not of the image description page), e.g. The URL can be found by checking with your browser the properties of the image when it is displayed on a webpage.

Conversely, to go to the image description page of an image referred to with external link style, put the URL in the address bar and replace "upload/alphanumerics/alphanumerics/" with "wiki/image:".

For inline images, put the url, preceded and followed by a space, in the text: a b gives a b

Without special formatting, inline images are positioned like this:

text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text

A table may be used to position the image(s) as desired. E.g.







WikiTeX ([4]) is a MediaWiki extension that can produce graphs of functions, various diagrams, etc. It is operational at , but not yet at Wikimedia projects. Note that one can anyway produce an image on Wikisophia, and subsequently upload it on any MediaWiki project.



Links to other help pagesEdit

Help contents
Meta · Wikinews · Wikipedia · Wikiquote · Wiktionary · Commons: · Wikidata · MediaWiki · Wikibooks · Wikisource · MediaWiki: Manual · Google
Versions of this help page (for other languages see further)
What links here on Meta or from Meta · Wikipedia · MediaWiki
Go · Search · Stop words · Namespace · Page name · Section · Backlinks · Redirect · Category · Image page · Special pages · Printable version
Tracking changes
Recent changes (enhanced) | Related changes · Watching pages · Diff · Page history · Edit summary · User contributions · Minor edit · Patrolled edit
Logging in and preferences
Logging in · Preferences · User style
Starting a new page · Advanced editing · Editing FAQ · Edit toolbar · Export · Import · Shortcuts · Edit conflict · Page size
Links · URL · Piped links · Interwiki linking · Footnotes
Style and formatting
Wikitext examples · CSS · Reference card · HTML in wikitext · Formula · List · Table · Sorting · Colors · Images and file uploads
Fixing mistakes
Show preview · Testing · Reverting edits
Advanced functioning
Expansion · Template · Advanced templates · Parser function · Parameter default · Variable · System message · Substitution · Array · Calculation · Embed page
Special characters · Renaming (moving) a page · Preparing a page for translation · Talk page · Signatures · Sandbox · Legal issues for editors
English · dansk · Deutsch · français · italiano · 日本語 · polski · português do Brasil · русский · shqip · Tiếng Việt · 中文(台灣)‎