Hacking Quicktags: One Image Directory, Under Eris
Okay, so here's some fun. At Needcoffee, we pretty much draw from a single directory for images. But if you do the IMG quicktag by itself, all you get is it asking you for the full URL. That's no fun. How can you hardcode the img directory in there?
Simple.
1. Go to wp-includes/js/
2. Edit your quicktags.js
3. Look for this code (I've killed some tabs just to keep it from being too wide for the theme):
function edInsertImage(myField) {
var myValue = prompt(quicktagsL10n.enterImageURL, 'http://');
if (myValue) {
myValue = '<img src="'
+ myValue
+ '" alt="' + prompt(quicktagsL10n.enterImageDescription, '')
+ '" />';
edInsertContent(myField, myValue);
}
}
4. Here's the change I made for Needcoffee:
function edInsertImage(myField) {
var myValue = prompt(quicktagsL10n.enterImageURL, 'http://images.needcoffee.com/');
if (myValue) {
myValue = '<div class="img-right"><img src="'
+ myValue
+ '" alt="' + prompt(quicktagsL10n.enterImageDescription, '')
+ '" /></div>';
edInsertContent(myField, myValue);
}
}
You'll notice that "http://images.needcoffee.com/" is set to pop up instead of just "http://". Obviously, you make that whatever you want it to be.
Now you'll also notice that I've got a div class in there instead of just the standard img src code. Well, at Needcoffee, our images are always on the right side of the post (well, normally), so that's hardcoded as well to save me from having to put it in.
Enjoy.
P.S. You might need to shut down your browser and flush your machine's cache before the changes show up. So don't panic if it doesn't take effect immediately.
No Comments »
RSS feed for comments on this post. TrackBack URL
