Sep
29
2007

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.

Written by Widge in: Wordpress | Tags: , ,

No Comments »

RSS feed for comments on this post. TrackBack URL


Leave a Reply

Widge and his truest friend

This is me.

No, really.

I am a writer, poet, spoken word performer, actor, singer, improviser, content creation and idea machine, freelance iconoclast, and the internet's janitor that dispenses pop culture wisdom to the protagonist of your choice. I have seen too many movies, read too many comic books, and when the zombies finally come, I'm the one you want to call. I sure as hell won't answer the phone, but it's the thought that counts. I advise people on the net, websites and technology, because I know these things instead of having a life or sleeping.

If you like something I've done, donate to the Widge Wants to Kill His Day Job Fund. Or if you'd like to hire me for a job, my rates are terribly reasonable. We thank you.

Powered by WordPress. Theme: TheBuckmaker's Aerodrome.