Extension:MsUpload

From Linux Web Expert

The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
MediaWiki extensions manual
MsUpload
Release status: beta
File:Msupload version 1.27 with wikieditor.png
Implementation API
Description Allows to upload multiple files via the editor including drag & drop
Author(s)
Latest version 13.5
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 Lua error in Module:Extension at line 172: bad argument #1 to 'inNamespace' (unrecognized namespace name 'skin').
Public wikis using Lua error in Module:Extension at line 172: bad argument #1 to 'inNamespace' (unrecognized namespace name 'skin').
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

  • Install the WikiEditor extension.[1] By default its editing toolbar is enabled for all users.
  • <translate> [[<tvar name=2>Special:ExtensionDistributor/MsUpload</tvar>|Download]] and move the extracted <tvar name=name>MsUpload</tvar> folder to your <tvar name=ext>extensions/</tvar> directory.</translate>
    <translate> Developers and code contributors should install the extension [[<tvar name=git>Special:MyLanguage/Download from Git</tvar>|from Git]] instead, using:</translate>cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/MsUpload
  • <translate> Add the following code at the bottom of your <tvar name=1>LocalSettings.php </tvar> file:</translate>
    wfLoadExtension( 'MsUpload' );
    
  • Configure as required.
  • File:OOjs UI icon check-constructive.svg <translate> Done</translate> – <translate> Navigate to <tvar name=special>Special:Version</tvar> on your wiki to verify that the extension is successfully installed.</translate>

Configuration

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

Extension features

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? (Not set by default)
$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

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

$wgEnableWriteAPI = true; // Enable the API
$wgEnableUploads = true; // Enable uploads
$wgAllowJavaUploads = true; // Solves problem with Office 2007 and newer files (docx, xlsx, etc.). Deprecated: Removed in 1.39+
$wgGroupPermissions['user']['upload'] = true; // Allow regular users to upload files
// Make sure that the file types you want to upload are allowed:
$wgFileExtensions = array('png','gif','jpg','jpeg','doc','xls','pdf','ppt','tiff','bmp','docx','xlsx','pptx');

Inserting PDFs as image thumbnails with PdfHandler

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.

<translate> {{<tvar name=1>#if: </tvar>|as of|As of}} <tvar name=2></tvar></translate>, 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

Known issues

You should know

  • 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

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

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

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

See also