Extension:SimpleBatchUpload

From MediaWiki.org
Jump to navigation Jump to search
MediaWiki extensions manual
Crystal Clear action run.svg
SimpleBatchUpload
Release status: stable
SimpleBatchUpload.png
Implementation Special page, Parser function
Description Basic, no-frills uploading of multiple files to MediaWiki
Author(s) Stephan Gambke
Latest version 1.4.0 (2018-10-24)
Compatibility policy master
MediaWiki 1.26+
PHP 5.4+
Database changes No
Composer mediawiki/simple-batch-upload
License GNU General Public License 2.0 or later
Download Latest stable
README
release-notes
Hooks used
ParserFirstCallInit
Translate the SimpleBatchUpload extension if it is available at translatewiki.net
Check usage and version matrix.

The SimpleBatchUpload extension provides basic, no-frills uploading of multiple files to MediaWiki at "Special:BatchUpload", using the jQuery File Upload JavaScript library.

Requirements[edit]

  • PHP 5.4 or later
  • MediaWiki 1.26 or later

Download[edit]

The recommended way to download this extension is by using Composer. To do that, just add the following to the MediaWiki composer.local.json file and run php composer.phar update mediawiki/simple-batch-upload from the MediaWiki installation directory.

{
	"require": {
		"mediawiki/simple-batch-upload": "~1.4"
	}
}

To update the extension, just run php composer.phar update mediawiki/simple-batch-upload again.

Alternatively, you can download a tar ball or zip file from GitHub, and extract it into the extensions directory of your MediaWiki installation.

Do not use Git to download this extension: the downloaded code will be incomplete, lacking, most notably, the jQuery File Upload library.

Installation[edit]

Add the following line to your LocalSettings.php:

wfLoadExtension( 'SimpleBatchUpload' );

To make sure that SimpleBatchUpload has been installed correctly, check that an entry for it exists at Special:Version and that Special:BatchUpload is working.

Note: To use the extension $wgEnableWriteAPI needs to be enabled and the user needs the writeapi right. Both is the default MediaWiki setting for registered users, but it may have been changed during the configuration of the wiki.

Usage[edit]

There are four ways to upload files using this extension:

  • Go to Special:BatchUpload to get a plain upload page
  • Go to Special:BatchUpload/Foo to get an upload page that sets {{Foo}} as the wikitext of the uploaded file's page
  • Add {{#batchupload:}} to any wikipage to get a simple upload button
  • Add {{#batchupload:Foo|Bar|Baz}} to any wikipage to get an upload button that sets {{Foo|Bar|Baz}} as the wikitext of the uploaded file's page

Note: The wikitext will only be set for newly uploaded files. If the file exists already, subsequent uploads of new versions of the file will not change the wikitext.


Customization[edit]

It is possible to specify dedicated upload pages for specific file types by editing the MediaWiki:Simplebatchupload-parameters page. Each line of that page is considered as one set of parameters.

Available parameters are:

  • Name of template to be stored as text on initial upload
  • Upload comment
  • Title line of the Special:BatchUpload/subpage page.

Parameters should be separated by pipes (|).

The line to be used is selected by appending the name of the template as the subpage to the URL of the Special:BatchUpload page.

  • Note: Spaces in the name of your template will cause this process to fail.

Example:

Consider the parameter line

 Pics | These pics were uploaded using [[mw:Extension:SimpleBatchUpload{{!}}SimpleBatchUpload]] | Upload some pics!
  • This can be selected by going to Special:BatchUpload/Pics.
  • The title of this page will be Upload some pics!.
  • The comment for the upload will be These pics were uploaded using SimpleBatchUpload.
  • If a file with that name is uploaded for the first time it will have {{Pics}} as wikitext.

Configuration[edit]

$wgSimpleBatchUploadMaxFilesPerBatch: Array defining the maximum number of files that can be uploaded each time depending on the user group. When a user is trying to upload larger batches of files an error message is displayed.

Default:

$wgSimpleBatchUploadMaxFilesPerBatch = [
	'*' => 1000,
];

Note: Be aware that this is neither the right setting to block file uploads, nor to throttle them! Users can still use the normal file upload or the MediaWiki API. For selectively blocking uploads see Manual:Configuring_file_uploads. For throttling uploads see Manual:$wgRateLimits.

See also[edit]