Skip to content

Latest commit

 

History

248 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SimpleBatchUpload

GitHub Workflow Status Latest Stable Version Packagist download count

The SimpleBatchUpload extension provides basic, no-frills uploading of multiple files to MediaWiki.

It is maintained by Professional Wiki. Contact us for commercial support or MediaWiki development.

Requirements

  • PHP 8.0 or later
  • MediaWiki 1.43 or later

Use SimpleBatchUpload 2.x for older versions

Installation

Composer

COMPOSER=composer.local.json composer require --no-update mediawiki/simple-batch-upload:^4.0
composer update mediawiki/simple-batch-upload --no-dev -o

Manual installation

Download and place the files in a directory called SimpleBatchUpload in your extensions/ folder.

Enable the extension by adding the following to your LocalSettings.php:

wfLoadExtension( 'SimpleBatchUpload' );

Usage

See the SimpleBatchUpload usage documentation.

Customization

It is possible to specify dedicated parameter sets for the upload of 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 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.

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 [[mw:Extension:SimpleBatchUpload{{!}}SimpleBatchUpload]].
  • If a file with that name is uploaded for the first time it will have {{Pics}} as wikitext.

Renaming files on upload

Files are renamed under Rename files, above the file list: Find is looked for in each file name and replaced with Replace with. Each row shows the name its file will be uploaded under before Upload is pressed, and renaming is applied before the batch checks whether two files would be uploaded under one name.

  • As plain text, every occurrence is replaced, matching case, and the file extension is left alone. An empty Find puts Replace with in front: Trip- uploads IMG_0001.jpg as Trip-IMG_0001.jpg.
  • With Use regular expressions ticked, Find is a JavaScript regular expression matched against the whole name, extension included, and every match is replaced. In Replace with, $1 stands for the text matched by the first (...) group, along with the rest of JavaScript's replacement syntax.

A name left without a file extension is marked on its row. The file is still sent, and the wiki adds an extension from what the file turns out to be.

A page can bring a rule with it, as a +rename parameter in the parser function:

{{#batchupload:Pics|+rename = /^IMG_/-->Holiday-}}

The parameter fills in the fields when the page opens, with Use regular expressions ticked, and is not stored on the file page. It takes a regular expression and a replacement separated by -->. The pattern is delimited by #, /, @ or ! — whichever does not appear in the pattern itself — and may be followed by any of the flags g (replace every match, not just the first), i (ignore case), m, u and y. Typed into the text for each file page inside a template call, it moves into the fields when the text field is left. It cannot be set in a parameter line on MediaWiki:Simplebatchupload-parameters, whose first field is the template name alone.

Configuration

Available configuration options:

  • $wgSimpleBatchUploadMaxFilesPerBatch - Array defining the maximum number of files that can be uploaded each time depending on the user group.
    Default:
$wgSimpleBatchUploadMaxFilesPerBatch = [
	'*' => 1000,
];

Note: Be aware that this is not the right setting to completely block file uploads! Users can still use the normal file upload or the MediaWiki API. See the paragraph on user permissions on Configuring file uploads on mediawiki.org.

License

GNU General Public License 2.0 or later

Releases

Sponsor this project

Used by

Contributors

Languages