Editing WordPress QuickTags to automatically create captioned images
April 8, 2006 Web Programming 9 Comments![]() |
One of the best ways to add life to your
Thanks to
First, replace the function
function edInsertImage(myField) {
var myValue = prompt(’Enter the URL of the image’, ‘http://’);
if (myValue) {
myValue = ‘<img src="’
+ myValue
+ ‘" alt="’ + prompt(’Enter a description of the image’, ”)
+ ‘" />’;
myValue = ‘<table class="alignright" width="’
+ prompt(’Enter the image width’, ‘250′)
+ ‘" border="’
+ prompt(’Border size:’, ‘0′)
+ ‘" cellspacing="0" cellpadding="0">’
+ ‘<caption align="bottom"><b>’
+ prompt(’Caption:’, ”)
+ ‘</b></caption><tr><td>’
+ myValue
+ ‘</tr></td></table>’;
edInsertContent(myField, myValue);
}
}
Now, at this point, once you’ve replaced your current quicktags.js, the ‘img’ button on the write page may or may not do what you want it to do. Chances are that you’ll have to add to your
table.alignright {
padding: 4px;
margin: 0 0 2px 7px;
display: inline;
}
table.alignleft {
padding: 4px;
margin: 0 7px 2px 0;
display: inline;
}
That should do it. Now whenever you go to add an image with the quicktags
UPDATE: Make sure you refresh the ‘Write Post’ page of WordPress after you modifiy your quicktags.js file. Otherwise, the cached (unmodified) version will continue to be used.

