Working With MediaWiki
looking at the file’s internal file type, which the web server determines — the allowed set of file suffixes is really just shorthand for the allowed set of file types.
To add to or change the allowed set of file types, use the “$wgFileExtensions” variable in LocalSettings.php. The most common addition is allowing PDF files — to do that, you would add the following line:
$wgFileExtensions[] = 'pdf';
Extensions for uploading
A MediaWiki extension, UploadWizard, provides a nicer approach to uploading than the standard one, by guiding users on a step-by-step process that explains all the different options, like the copyright license used. It was developed for use on Wikimedia Commons (the wiki that holds the uploaded files for Wikipedia and other Wikimedia projects), but it can also be used on standard wikis; though some of the wording is unfortunately Wikimedia-specific, and can’t easily be customized away. You can read more about the extension here:
https://www.mediawiki.org/wiki/Extension:UploadWizard
There’s another extension, MultiUpload, that lets users upload more than one file at the same time; which can be useful when there’s a large set of images to be added. At the moment, this extension is somewhat unmaintained, and may have problems depending on your MediaWiki version, but when it works it’s quite useful:
https://www.mediawiki.org/wiki/Extension:MultiUpload
Finally, uploads are possible via Semantic Forms. Uploading from within a form has the advantage that the name of the file gets automatically placed on the page after it’s uploaded, so that users don’t need to do the second step of inserting a tag to display the image/file on the wiki page after they’ve uploaded it. For more on this option, see Chapter 17 .
Displaying images
Images are generally displayed by simply linking to the image — which is a somewhat unexpected syntax. Let’s say there’s an image on the wiki called “Easter Island.png”. The simplest way to display it is to just have the following:
[[Image:Easter Island.png]]
Alternatively, you could have this instead, since “Image” and “File” are aliases for the same namespace:
[[File:Easter Island.png]]
For the rest of this example, we’ll just use “Image”.
There are various additional settings you can apply to images: the height and width, the horizontal and vertical alignment, the caption, where the image links to, whether to place a border, etc. These are all parameters that can be added to the image tag, separated by pipes. Some are named, while others are unnamed.
Here’s an example of an image display with more parameters set:
[[Image:Easter Island.png|100px|x150px|right|link=Easter Island info|This is Easter Island.]]
The parameters can be passed in in any order, so the parser determines what parameter each value corresponds to, based on the specific text in each (except for a few named parameters like “link=”). A “px” value without an “x” at the beginning sets the width, while one with an “x” at the beginning sets the height. “
right
” here controls the horizontal alignment of the image — the other options are “
left
”, “
center
” and “
none
”.
The “
link=
” parameter sets the location that the image links to — it can be either a wiki page or a URL. By default, an image links to its own page.
The last parameter, unless it’s obviously something else, sets the caption for the image.
The only other very important setting for images is being able to display a thumbnail— most of the time, when images are displayed, it’s actually a thumbnail that’s shown, rather than the full-size image. To display an image as a thumbnail, just add the parameter “
|thumb
” to the image tag.
What if you just want to link to an image, rather than display it? You can either link to the wiki page for the image, or to the image itself. To link to the image’s wiki page, just add a colon at the beginning of the link, so it looks like:
[[:Image:Easter Island.png]]
If instead you want to link directly to the image, use the “Media” namespace instead, which exists just for this purpose. You could do:
[[Media:Easter Island.png|Click here to see a great picture.]]
There’s more customization that can be done of image display. This page has all the details, as well as a lot of helpful demos:
https://www.mediawiki.org/wiki/Help:Images
Image galleries
The built-in MediaWiki tag lets you display
Weitere Kostenlose Bücher