Hacking Quicktags: One Image Directory, Under Eris
Posted on 09.29.07 by Widge @ 10:55 pm

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.


Taggification: , ,

Filed under: Wordpress
Comments:

« Wordpress and the Illuminati | Hacking Quicktags: All Links Are Not Created Equal » No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

(required)

(required)



John Robinson is a writer of prose, poetry and comics who also writes under the pseudonym of Widgett Walls.

Widgett Walls is the director of Needcoffee.com who also writes under the pseudonym of John Robinson.

Don't ask.


This is my latest book. Short stories written especially for you, or at least someone who reminded me a lot of you at the time.

Read it for free here. Or if you like paper, buy it here.

Then tell all your friends about it. Or all your enemies. I'm not particular either way.


Want a translation? Try these:

They're not perfect, but they'll do in a pinch.







Syndication
Feedburner

Amigos
Sarah Brown
Catalyst
Dindrane
Doc Ezra
Tee Quillin
ScottC
Tibby's Bowl
JM Tuffley

Sites Which Distract Me From Writing
Boing Boing
Cringely
Defamer
Warren Ellis
Engadget
Fortean Times
Long Tail
Porphyre
Reason
Wired

Topics
General BS
Insomnia
Travel
Writing Fodder

Active Projects...
Dark Blue Monstropolis
Magnificent Desolation
Something Else
The Sunday Before You


Recent Entries
  • And Now That I've Upgraded to 2.6...
  • Don't Mind Me.
  • Amazon MAB Replacement?
  • My New Mascot
  • A Nice Coda to the Trip
  • The New Yorker Hotel Business Center
  • Blast From the Past
  • Crossposted From My StumbleUpon Blog
  • Update at Last
  • George Clooney Makes Small Films Profitable. Yes.
  • On the Other Side of the Flu
  • Piano and Trumpet For the Win
  • Gun, With Occasional Weightlessness
  • Tor Nørretranders on Permanent Reincarnation
  • Can I Get a Hell Yeah?

  • Wordpress Archives
    July 2008
    May 2008
    April 2008
    March 2008
    February 2008
    January 2008
    December 2007
    November 2007
    October 2007
    September 2007
    August 2007
    July 2007
    June 2007
    May 2007
    April 2007
    March 2007
    February 2007
    January 2007
    December 2006
    November 2006
    October 2006
    September 2006
    August 2006
    July 2006
    June 2006
    May 2006
    April 2006
    March 2006
    February 2006
    January 2006
    December 2005
    November 2005
    October 2005
    September 2005
    August 2005
    July 2005
    June 2005
    May 2005
    April 2005
    March 2005

    Credits and Copyright
    Proudly powered by WordPress. All content © 1997-present by John Robinson.
    Theme by Theron Parlin, but we've mangled it beyond all reason. So don't blame him.