PreloadFileDescription is a script that allows you to specify custom text (ex. template code) that will be preloaded when uploading files via:

It also has few other useful features:

  • Support for multiple custom text templates selectable via a dropdown menu (like licenses)
  • Ability to select specific license as default


This script can support a single preloaded text template without a dropdown menu or multiple templates. Regardless of the mode you need to import the script.



Add this JavaScript on your wiki:

Global Personal Site-wide
w:Special:Mypage/global.js Special:Mypage/common.js MediaWiki:Common.js
    type: 'script',
    articles: [
importArticles — Best Practices for installing JavaScript on FANDOM
The importArticles statement is designed to combine multiple HTTP requests into a single data transfer, allowing multiple scripts to load and execute faster. If you've been installing several different scripts, your JavaScript file has probably accumulated unnecessary import statements. Click "Expand" to learn how to efficiently batch import scripts to speed up performance and make your code look cleaner. One other approach is by using the MediaWiki:ImportJS.
If your JavaScript file has several lines of code that say importScript, importScriptPage, or importArticles, you may be able to combine them! By batch importing a collection of scripts with a single import, your JavaScript code will load faster and look cleaner. Consider the example below. On the left is an example of what your JavaScript file might currently look like. On the right is how you could improve that code.
Multiple imports — messy and slow One import — clean and efficient
  type: 'script',
  article: 'u:dev:FloatingToc/code.js'
importScriptPage('page1.js', 'wikiname');
importScriptPage('page2.js', 'wikiname');
    type: 'script',
    articles: [
Note: In this example, pay close attention to the placement of commas and other punctuation. For people who aren't familiar with programming (and even those who are!), a common mistake when writing code is to accidentally delete, forget, or misplace critical symbols like commas or quotation marks. This can cause a syntax error that breaks the code. Carefully follow the convention shown here when using importArticles.
But there's much more to importArticles than just this! For more examples and advanced usage, see the help page at Help:Including additional JavaScript and CSS.

Remember to specify configuration above importArticles.


To import the script, you can add the following line to your MediaWiki:ImportJS

Single template

You can specify text to preload as a value of PFD_template variable. Use \n to add line-break in the code.

PFD_template = '{{example info template\n| Parameter 1 = \n| Parameter 2 = \n}}';

Multiple templates

If you want to add ability to select the text that is preloaded from few different options that use different template or have additional categories.

In this case PFD_templates is a list that contains objects with template properties or strings that will generate group names inside the dropdown menu.

The first template on the list will be preloaded at the start.

PFD_templates = [
        label:   'Default template',
        desc:    '{{File\n| Description = \n| Date = \n| Source = \n| Author = \n| Other versions = \n}}',
    'Group header',
        label:   'Icon',
        desc:    '{{File\n| Description = \n| Date = \n| Source = \n| Author = \n| Other versions = \n}}\n[[Category:Icons]]',
        label:   'Portrait',
        desc:    '{{File\n| Description = \n| Date = \n| Source = \n| Author = \n| Other versions = \n}}\n[[Category:Portraits]]',


There are few additional variables that allow to modify behavior.

  • PFD_language – by default script will display messages in language user has set (and fallback to English if it's not present – More in section: #i18n). You can force script to display text in specific language by providing a language code. Example:
PFD_language = 'en';
  • PFD_messages – override messages with custom content – More in section: #i18n. Example:
PFD_messages = {
    'en': {
        'template-change-notice': 'If you change the template, your description\'s gonna have a bad time.',
  • PFD_license – you can specify license template to be selected by default. Put template name (first part of the entry from Mediawiki:Licenses) as a value. (case sensitive) Example:
PFD_license = 'Fairuse';
  • PFD_requireLicense – when set to true script will disable file upload until proper (non-empty) license is specified. Example:
PFD_requireLicense = true;
  • PFD_discourageEditorFileUpload – when set to true script will display a short notice when using media uploader from inside the editor (right rail). Example:
PFD_discourageEditorFileUpload = true;

Template entry object

The object with info about the template also has two optional properties:

  • altdesc – allows you to specify alternative version of the same template. It'll add two buttons below the description area that allow to switch between the two. Using this method rather than specifying a different template is good for keeping the list compact and having more options. Taking Polish League of Legends Wiki as an example: some templates have an alternative version which include code that automatically fills some parameters if the file has a proper name – allowing uploading multiple files without the need to fill the description separately. (long story short: I needed it so I implemented it ^^)
  • license – script will automatically select specified license when this template is selected (and revert to previously selected one when changed back)

Example code with all properties specified:

        label:   'Label',
        desc:    '{{Some template}}',
        altdesc: '{{Some template|with some slight changes}}',
        license: 'Fairuse',
        tip: 'Explanation template',


This script doesn't have that much messages, but still if you would like for it to support your language drop a translated code below on the talk page (or add it to the code if you're confident you won't break it ;)). Thanks

    'en': {
                'alternative-version': 'Alternative',
                'basic-version': 'Basic',
                'multiple-versions': 'This template is available in two versions:',
                'template-change-notice': 'Changing the template will overwrite current description.',
                'confirm-overwrite': 'Description has been modified.\nDo you want to overwrite it with a new template?',
                'discourage-editor-file-upload': 'This wiki encourages usage of <a href="/wiki/Special:Upload">Special:Upload</a> for uploading files.',
                'discourage-continue': 'Continue',
                'disabled-submit': 'Choose a license in order to upload a file',

You can also add a language, override all or some of the messages locally by specifying them in the PFD_messages variable.

Start a Discussion Discussions about PreloadFileDescription

  • PreloadFileDescription

    7 messages
    • My bad. The fallback part in the function that gets the message was failing in the dumbest of ways :P (looking for a key in undefin...
    • Thank you all for the help:)