Working With MediaWiki
every file in the /images directory. This approach has the advantage of simplicity, and for smaller wikis it’s just as good a solution. To enable this approach, add the following to LocalSettings.php:
$wgEnableHashedUploads = false;
If you’re going to use this setting, you should ideally do it before any files are uploaded. If, however, you want to change this setting for a wiki that already has uploaded files, you’ll probably have to re-import the files (see here ).
Thumbnails
A thumbnail is a small image meant to represent an uploaded file. For files that are images, these are simply smaller versions of the original image (or, for images that are already small, versions of the same size). For non-image files, these tend to just be an icon: for PDF files, for instance, it’s the Adobe Acrobat logo.
Thumbnails are used to represent images in various places within the wiki. Most importantly, they can be used to display the image on wiki pages -- we’ll get to the syntax and options for displaying images later in this chapter. Thumbnails are also used to show the version history of each file, within its own page. They are also used in the Special:ListFiles page (see here ), in image galleries, and in category pages, and they’re used when querying images in Semantic MediaWiki, with formats such as "table" and "gallery" (see here and here , respectively).
Troubleshooting uploading
It could be that, when you try to upload files on a wiki, you’re not allowed to. That could be for any of the following reasons:
PHP on the server is blocking uploads
The /images directory is not writable by MediaWiki
MediaWiki itself has uploading disabled
your user account is not allowed to upload.
If it looks like PHP is blocking uploads, add the following line in php.ini:
file_uploads = On
If the images directory is not writable, the solution depends on the web server and file system in question — this page holds more information:
https://www.mediawiki.org/wiki/Manual:Configuring_file_uploads
Uploading also needs to be enabled in MediaWiki itself — make sure that you have the following line in LocalSettings.php:
$wgEnableUploads = true;
By default, every logged-in user is allowed to upload files, but unregistered users aren’t. This can be changed in LocalSettings.php, via the ’upload’ permission. (There’s also a second relevant permission type, ’reupload’, for uploading files that already exist on the wiki and thus overwriting their contents.) To prevent regular users from uploading, for instance, you could add the following to LocalSettings.php:
$wgGroupPermissions['user']['upload'] = false;
$wgGroupPermissions['sysop']['upload'] = true;
And it may be that you’re allowed to upload files in general, but the specific file you have can’t be uploaded. That could be for two reasons: the file’s size, or its file type.
Every wiki has a limit on the allowed size of uploaded files, which is set by a combination of four PHP and MediaWiki settings. Essentially, the smallest of these dictates what is allowed to go through, so you may need to change all four to increase the allowed limit on file sizes. There are two PHP settings: “post_max_size” and “upload_max_filesize”, both of which would need to be changed in php.ini. The two MediaWiki variables are $wgUploadSizeWarning and $wgMaxUploadSize — both represent a number of bytes. $wgUploadSizeWarning sets only what file size results in a warning to the user, so it doesn’t actually affect which files go through and which don’t — but it should be made consistent with what the actual limits are. So, to change the allowed file size to 30 megabytes, you would change the following in php.ini:
post_max_size = 30M
upload_max_filesize = 30M
...and add the following to LocalSettings.php:
$wgUploadSizeWarning = 30 * 1024 * 1024;
$wgMaxUploadSize = 30 * 1024 * 1024;
File type restrictions
As for file types — only a limited set is allowed by default, because certain file types, likeMicrosoft Office documents (Word, Excel and the rest) can contain viruses, which unsuspecting users can end up installing on their systems if they download the file. The default set of file extensions allowed is very short: only “png”, “gif”, “jpg” and “jpeg” (with the last two both representing JPG files).
What if someone tries to upload a .doc file simply by renaming the file’s extension to, say, “.gif”? Thankfully, MediaWiki guards against that by
Weitere Kostenlose Bücher