Jump to content

Extension:MsUpload

From mediawiki.org
MediaWiki extensions manual
MsUpload
Release status: stable
Implementation API
Description Allows to upload multiple files via the editor including drag & drop
Author(s)
Maintainer(s) Sophivorus
Latest version 14.0 (2024-08-13)
Compatibility policy Master maintains backward compatibility.
MediaWiki >= 1.41.0
License GNU General Public License 2.0 or later
Download
  • $wgMSU_checkAutoCat
  • $wgMSU_showAutoCat
  • $wgMSU_uploadsize
  • $wgMSU_imgParams
  • $wgMSU_useDragDrop
  • $wgMSU_confirmReplace
  • $wgMSU_useMsLinks
Quarterly downloads 235 (Ranked 22nd)
Public wikis using 6,278 (Ranked 35th)
Translate the MsUpload extension if it is available at translatewiki.net
Issues Open tasks · Report a bug

The MsUpload extension allows users to upload multiple files by drag & drop in the standard MediaWiki edit page.

Features
  • Easily upload one or multiple files simultaneously.
  • File upload integrated in the edit page.
  • Upload via drag and drop (if HTML5 is available in browser).
  • Add the file into the edit page as a link.
  • Add the files into the edit page as a gallery.
  • Change the name of the file before uploading.
  • Add files to the current category, if the page being edited is a category page.

Installation

[edit]
  • Install the WikiEditor extension.[1] By default its editing toolbar is enabled for all users.
  • Download and move the extracted MsUpload folder to your extensions/ directory.
    Developers and code contributors should install the extension from Git instead, using:cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/MsUpload
  • Add the following code at the bottom of your LocalSettings.php file:
    wfLoadExtension( 'MsUpload' );
    
  • Configure as required.
  • Yes Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Configuration

[edit]

An editor can embed the files into the editor as a list of MsLinks with Extension:MsLinks .

Extension features

[edit]

Below are the special extension features that you can set in your LocalSettings.php along with their default values:

$wgMSU_useDragDrop = true; // Should the drag & drop area be shown?
$wgMSU_showAutoCat = true; // Files uploaded while editing a category page will be added to that category
$wgMSU_checkAutoCat = true; // Whether the checkbox for adding a category to a page is checked by default
$wgMSU_useMsLinks = false; // Insert links in Extension:MsLinks style?
$wgMSU_confirmReplace = true; // Show the "Replace file?" checkbox
$wgMSU_imgParams = '400px'; // Default image parameters, for example "thumb|200px"
$wgMSU_uploadsize = '100mb'; // Max upload size through MsUpload

Relevant global configuration variables

[edit]

Below are some of the relevant global configuration variables that you can set in your LocalSettings.php :

$wgEnableUploads = true; // Enable uploads
$wgMimeTypeExclusions = [ ... ]; // Remove "application/java" from this configuration parameter. Solves problems with Office 2007 and newer files (docx, xlsx, etc.)
$wgGroupPermissions['user']['upload'] = true; // Allow regular users to upload files
// Make sure that the file types you want to upload are allowed:
$wgFileExtensions = [ 'png', 'gif', 'jpg', 'jpeg', 'doc' ,'xls', 'pdf', 'ppt', 'tiff', 'bmp', 'docx', 'xlsx', 'pptx' ];

Inserting PDFs as image thumbnails with PdfHandler

[edit]

When processing regular bitmap image types with extensions like .jpg and .png, MsUpload will offer you the option of inserting a link to the image (e.g., [[:File:Image.jpg]]), or embedding the image in the page itself (e.g., [[File:Image.jpg|thumb|400px|Image caption]]).

MsUpload does not offer this option for files with .pdf extensions by default. However, if you have Extension:PdfHandler installed, PDF files get their own bitmap thumbnails that can be inserted into articles with [[File:…]] links, just as with other conventional bitmap image types, so it makes sense to have MsUpload treat PDFs just as any other image.

As of , the switch ( file.extension ) block which handles this is around line 188 in extensions/MsUpload/MsUpload.js. Look for the case 'pdf': clause that handles PDFs (around line 212) and add file.group = 'image'; so that the case clause ends up looking like this:

    
    case 'pdf':
      file.group = 'image';
      file.li.type.addClass( 'pdf' );
      break;
}

Having made that change, Shift+reload or ⌘+reload your browser so that the new JavaScript source file is fetched from the server, rather than cache, and next time you upload a PDF, you should see both the "Insert as link" and the "Insert as image" links made available.

Recent changes

[edit]

Known issues

[edit]

You should know

[edit]
  • Without HTML5 support Adobe Flash is used.
  • The maximum file size depends on MediaWiki settings but a lower limit may be set.
  • Uses the plupload upload handler, which comes included with the extension
  • Adds an upload icon to the editor and WikiEditor .

This file did not pass file verification

[edit]

If the message "This file did not pass file verification" appears, add the following to LocalSettings.php :

$wgAllowJavaUploads = true; #Deprecated: Removed in 1.39+

If this is not enough additionally set the following in LocalSettings.php (works for MW 22 & 24):

$wgVerifyMimeType = false;

If you still cannot upload "ppt" files, try to save them as "pptx" and upload the "pptx" version.

Invalid CSRF token

[edit]

The Invalid CSRF token message means that your browser couldn't create a secure cookie, or couldn't access that cookie to authorize your login.

Google Chrome
Open Settings, Advanced, Privacy and security, Content Settings, Cookies, Allow, Add and enter e.g. [*.]yourwiki.domain, logout and login again to the wiki.
Firefox
Open Options, Privacy & Security, Cookies and Site Data, Exceptions, enter e.g. https://yourwiki.domain, Save Changes, logout and login again to the wiki.
Safari
Open Preferences, Privacy, ensure that Cookies and website data is set to allow, logout and login again to the wiki.

References

[edit]
  1. Note that there is a plan to remove this dependency.

See also

[edit]