Manual:Custom edit buttons

Jump to: navigation, search
Old toolbar

You have to differentiate between the old toolbar and the new one added by Extension:WikiEditor.

To add new buttons you need to include them in your personal JavaScript. In Localsettings.php add $wgAllowUserJs = true; or in the MediaWiki:Common.js or as a Gadget.

§Extension:WikiEditor[edit | edit source]

jQuery(document).ready(function ($) {
    $('#wpTextbox1').wikiEditor('addToToolbar', {
        section: 'advanced',
        group: 'format',
        tools: {
            buttonId: {
                label: 'Comment visible only for editors',
                type: 'button',
                icon: '//',
                action: {
                    type: 'encapsulate',
                    options: {
                        pre: "<!-- ",
                        peri: "Insert comment here",
                        post: " -->"
See: Extension:WikiEditor/Toolbar customization for more on the wikiEditor

You may also use the InsertWikiEditorButton script (by Krinkle) to simplify adding buttons to the wikiEditor.

mw.user.options.get( 'usebetatoolbar' ) can be used to check if a user is using the wikiEditor (true) or the old toolbar (false).

§Classic edit toolbar[edit | edit source]


§Add buttons[edit | edit source]

You can add custom edit buttons to the edit toolbar above the edit window.

To add custom edit buttons, edit one of:

User:Your username/skinname.js -- the buttons will only show up for yourself. (System admins: Ensure you have $wgAllowUserJs set to true in your wiki's Localsettings.php.)
or MediaWiki:Common.js -- affects all wiki users.


if ( mw.toolbar ) {
    mw.toolbar.addButton( {
        imageFile: '//',
        speedTip: 'Comment visible only for editors',
        tagOpen: '<!-- ',
        tagClose: ' -->',
        sampleText: 'Insert comment here',
        imageId: 'button-comment'
    } );
  • imageFile is the full URL address to the edit button image.
  • tagOpen is the opening tag, in this example: <!--
  • tagClose is the closing tag, in this example: -->
  • sampleText is the sample text that will appear between the opening and closing tags. The editor should replace this sample text with his or her own text.

§Example: using a script on Unix, Linux, Mac[edit | edit source]

To use a script for downloading images from English Wikipedia:

Create a file with the URLs:

$ cat >urls

Download images with wget

$ wget -N -i urls

§See also[edit | edit source]

Language: English  • 日本語 • русский