Wordpress Flickr Post Bar and Markdown

I’m a big fan of Markdown and the portability it brings, but manually adding thirty photos to an otherwise small post was driving me up the wall so I did a little googling and came across the *Wordpress Flickr Post Bar* by [Joe Tan](http://tantannoodles.com/toolkit/wp-flickr-post-bar/ “Bar Homepage”).

The Bar works by adding a bar along the bottom of your wordpress posting box, that displays thumbnails which you can then drag into your post. An extremely effective solution (good work Joe!) it has one downside for my needs, rather than inserting Markdown for the image I’m trying to add it inserts HTML.

After emailing the author a feature request I did a little poking around in his code and came up with a temporary solution until he is able to implement Markdown support more fully. My approach was to simply replace the hardcoded html he was using with hardcoded Markdown. This of course means that Markdown will ALWAYS be inserted, but for my needs that was fine.

The file that contains the pertinent code is *”post-bar-form.html”* and the particular function is named *tantan_onClick* and starts on line 72. I commented out his code, and added my own as shown here, which starts on line 75. (Please note that I have reformatted the code for easier reading)

if (textarea && photo)
{
//var html = ‘'+photo[4]+'‘;
var html = ‘!['+photo[4]+’](’+photo[0]+’)';

if (photo[1] != ”)
{
//html = ‘‘+html+’ ‘;
html = ‘['+html+'](’+photo[1]+’ “‘+photo[4]+’”)’;
}
else
{
html += ‘ ‘;
}

if (window.top && window.top.window.tinyMCE)
{
var mce = window.top.window.tinyMCE;
mce.execCommand(’mceInsertContent’, false, html);
}
else
{
addText(textarea, html);
}
}

Overwrite the modified *”post-bar-form.html”* file on your server with the modified version, and the Bar will insert Markdown rather than HTML.

Special thanks go to Joe Tan and his fantastic work on the Wordpress Flickr Post Bar which can be found at [http://tantannoodles.com/toolkit/wp-flickr-post-bar/](http://tantannoodles.com/toolkit/wp-flickr-post-bar/ “Bar Homepage”).

Tags: , , , ,

This entry was posted on Wednesday, March 22nd, 2006 at 9:20 pm and is filed under Wordpress. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

4 Responses to “Wordpress Flickr Post Bar and Markdown”

PreMagination » Blog Archive » Markdown and the Flickr Photo Album for Wordpress Plugin March 23rd, 2006 at 8:04 pm

[...] Not one day after I post instructions on how to modify the Wordpress Flickr Post Bar Joe Tan releases a massive upgrade in the form of the Flickr Photo Album for Wordpress. After a receiving a helpful hint from Joe on where to start I’d like to share my hack that replaces the HTML inserted by the plugin with Markdown. [...]

YAWPU April 5th, 2006 at 1:29 pm

Hi, I found your link on the plugin’s comment page.
I see that you use the Hemingway theme on this site. I’m giving it a try right now, and just installed Joe’s Flickr Photo Album with it on a test install. It seems to work ok on posts, but album pages seem to break the theme. Are you using the Photo Album pages on this site? TIA.

YAWPU April 6th, 2006 at 6:44 am

Ok found it if ever someone stumbles upon this post: you need to add an initial div id=”primary” and div class=”inside” tags + closing tags to album.html, photo.html, and albums-index.html

Drew Loika April 6th, 2006 at 9:30 am

Hey YAWPU, thanks for the followup post. You can see my photo albums at http://www.premagination.com/photos/ and while they’re kinda ugly they don’t appear to “break” the theme. Are you seeing something different than I am?

Leave a Reply