Manual talk:Custom edit buttons

Placing username and timestamps (by ~)
Hi, I want to place templates with this button. One of them needs username (3x ~) and timestamp (5x ~) as attributes, but I cannot add them to Common.js because they alway get replaced when I save. Is there any way to do this? if (mwCustomEditButtons) { mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images.wikia.com/central/images/7/74/Button_comment.png", "speedTip": "Insert comment", "tagOpen": "{\{NKS|name|timestamp}}\n",  < here is the problem, ~ should be there instead "tagClose": "\n{\{NKE}}", "sampleText": "comment"} } --87.176.88.157 14:34, 27 November 2009 (UTC)

Is this supposed to be an extension? -- Anon  Diss  05:18, 7 March 2008 (UTC)
 * I agree, it looks like it should be made into an extension, currently you have to modify the codebase which is not good practise. --Zven 19:01, 20 March 2008 (UTC)

It looks like the slashes used for escaping newlines and apostrophes are out of whack. It was easy enough to fix the extra slashes for he apostrophes, but I'm not sure how to properly escape the newlines needed for the gallery and table. Can someone figure it out? --66.142.154.217 09:50, 20 March 2008 (UTC)
 * Figured it out, to escape a newline you need to use " instead of an apostrophe. I updated the article to reflect this and removed the buttons that are in mediawiki by default, to remove confusion and potential future problems --66.142.154.217 10:10, 20 March 2008 (UTC)
 * Using "\n" makes a like break in "open" but it doesn't work in "close". Please help.

Example: 'open'	=>	" \n", 'close'	=>	'\n ',

will result in: Text\n

insteaf of

Text --Yakushi.kabuto 10:35, 7 April 2008 (UTC)
 * \n doesn't work with single quotes, only with double quotes, so use "\n ". --Catrope 12:15, 8 April 2008 (UTC)


 * If you break the line into multiple strings that are concatenated you can avoid a lot of the conversion problems. (Also, you can escape double quotes with \")
 * IE "\n{" + "{PAGENAME}" + "}\n{" + "{TemplateX|Var1=\"alpha\"}" + "}\n",
 * Extra splits of the string cause no harm. Split it wherever you think there might be a problem. All my other JS function on the same page die when there is a problem. -_- ~JSarvis

will not work
I can not get Custom edit buttons to work I am using 1.6

I have MediaWiki:Common.js or do I place it in monobook.js?

--60.231.4.249 14:27, 22 May 2008 (UTC)

Is this page outdated ?
The FAQ states a different code and the one provided here didn't work for me on MediaWiki 1.15.1 (neither in Common.js, nor in the user/skin.js). The code from the FAQ works, but only in Common.js. Is there another way, to have custom buttons, or should it be working anyway? -- Sidcom 23:10, 22 February 2010 (UTC)
 * This code is right. It work for me on v15.--Juan de Vojníkov 15:06, 7 May 2010 (UTC)

Please do not hotlink images...
Is this phrase still relevant? Once we can mirror images from Commons.--Juan de Vojníkov 15:02, 7 May 2010 (UTC)

Creating custom edit buttons with popup windows for further input
Hi im trying to build a mediawiki extension which requires AJAX calls during editing a page. All I need is to add a new edit button on the edit page which displays a javascript popup editor which in turn makes the appropriate calls.

I need to know if it is feasible in Mediawiki, to inject javascrpt code into edit buttons.

Any kind of information or leads are welcome!

--Pradeep122 13:59, 20 June 2010 (UTC)

Download edit buttons with browser
I found the easiest way to download all images from Mediawiki edit toolbar is to use your browser's "Save page as" function. This will download all images from that website into a subfolder on your PC. hth --Nakohdo 16:02, 21 January 2011 (UTC)

Edit existing Edit Buttons
Is it possible to edit the existing edit buttons or can I only add further buttons to the existing non-editable buttons?

E.g. I would like the existing Image-Button to give. 94.217.51.49 11:17, 21 July 2011 (UTC)


 * See http://old.nabble.com/editing-the-edition-buttons-tt29797811.html for some pointers. --Nakohdo 12:42, 21 July 2011 (UTC)


 * Perfect! Thank you very much! (/wiki/includes/EditPage.php &rarr; $toolarray) 94.217.51.49 10:17, 27 July 2011 (UTC)

Needing a condition when using deprecated style in monobook.js
In the deprecated section, I think that it needs some text or example that shows that you still need to add a condition for the newer addButton style to work. At English Wikisource, it was still necessary to wrap in  though I am not sure whether that is just a local or WMF issue alone.

— billinghurst  sDrewth  23:58, 13 May 2013 (UTC)

Use of "mwCustomEditButtons" is deprecated. Use mw.toolbar instead.
Yes, there are still many around. Krinkle or Helder.wiki, is this page the best resource to explain conversion of good old mwCustomEditButtons to mw.toolbar? Krinkle or Hoo, can you please run mwgrep and post somewhere a list of MediaWiki pages containing mwCustomEditButtons (so that I can warn them)? --Nemo 08:08, 1 June 2014 (UTC)
 * There is also an example at w:en:User talk:MarkS/Extra edit buttons. Helder.wiki 20:00, 1 June 2014 (UTC)

Adding JavaScript options
Added a section on the various ways that JavaScript delivering edit button functionality could be implemented. Mainly targeted extension developers as addition to JavaScript API's for MediaWiki seems to be an area where we can improve the documentation. Any thoughts on whether to move to a separate page and just reference here?

Iowajason (talk) 02:00, 20 March 2015 (UTC)


 * Yeah, some of the documentation here is in pretty bad shape. Since this manual page is in general more focused on people with a bit more expertise I think that it may stay here. Thank you for contributing. Cheers --&#91;&#91;kgh&#93;&#93; (talk) 09:26, 20 March 2015 (UTC)

Where is the page?
I was just wondering where's the page that is responsible for showing this toolbar? Épine (talk) 20:34, 24 August 2017 (UTC)

Extension:WikiEditor/Toolbar customization (linked at the end of the page) --Ciencia Al Poder (talk) 09:07, 25 August 2017 (UTC)
 * I mean the MediaWiki/Module page that shows the general toolbar every wiki has. Épine (talk) 12:31, 26 August 2017 (UTC)

Getting a bit complicated, doesn't it?
So, nowadays the proper code to add a button looks like this:

(update: as stated in following messages, the code below is obsolete. The current code is at Manual:Custom edit buttons.) And this is only for the old-style toolbar...

Od1n (talk) 10:22, 4 October 2017 (UTC)


 * Thanks for posting this.. They should put this in the main page, since the simple 'mw.toolbar.addButton' no longer works. -- Ivo


 * @Od1n: Thanks. I have updated the page with a current recommendation, please use that instead. The code posted by Od1n is not supported and may be slower and/or not work in some scenarios. --Krinkle (talk) 19:26, 2 April 2018 (UTC)