Flickr Stripper Saves The Day

July 7th, 2008 by Roderick Russell

flickrstripperHaving decided that I needed a decent moblogging solution for my self-hosted WordPress blog, I recently ran tests of several options open to me and my setup.

My needs were simple. While on the road I’m likely to post primarily photos and video with short bits of accompanying text commentary. No need for elaborate layouts, minimal-to-no links included and text commentary is – even with my legendary loquaciousness – usually no more than a few short paragraphs.

Preferring maximum control and self-contained systems, my first choice was of course to keep whichever solution I implemented as close to the core of WordPress as is possible, so naturally I investigated the WordPress-native “Post via E-Mail” solution. Unfortunately the system is, at least at the time of this writing, not handling images terribly well, though passing text through my phone into the system is working flawlessly. Alas, it was really the combination of photos, videos and text that I was interested in, so at this time the WordPress-native solution is not for me.

Not wanting to venture too far from the core of the code, I decided to explore several plugin options. There were many contenders, notable among them Brett Duncavage’s PostMaster 2.0. In fact, Brett’s plugin is quite good and handles images very, very well! There is a downfall to the plugin though, and that is the fact that - exactly inverse to the WordPress-native support - it does not handle text very well. This is no fault of the plugin author’s, of course. In fact, he’s worked very, very hard to keep up with and account for the myriad of idiosyncrasies that each cell carrier throws at him, but at this time the code is not handling messages from my carrier (Verizon) very well if they include more than, say, one short paragraph.


Venturing even further out of the WordPress system, I reluctantly decided to explore what options might be available via Flickr, as I have a Flickr Pro account that I use very regularly.

As it turns out, there are some great external blog integration options available through the Flickr system and, as I post most of my photos there anyhow and already upload via email from my cell phone, working through their system is quite convenient. It was very simple to integrate my blog and very easy to create a new private Flickr email address that I can use to post simultaneously to Flickr as well as my blog.

All seemed to be working perfectly, save for one thing; that is, the photos and blog posting appeared on Flickr just fine, but when passed into my self-hosted WordPress system the text exhibited an overwhelming number of seemingly random line breaks which in turn threw off the alignment of each entry, leaving it looking hideous, unkempt and difficult to read on the screen!

I searched and searched and searched for a solution and all I could turn up were numerous unanswered Flickr Help Forum posts (here, here, here, here, etc…). Many users were experiencing the exact same thing as me, and there was no solution to be had. In fact, many of the forum threads became closed due to lack of response!

The Flickr staff and development team has not been in a position to help much, as they themselves are rather stuck in the middle of cell carriers and email clients on one side and external, third-party blog servers on the other, each with their own proprietary setup.

Eager to get the system working for myself though I decided to take matters into my own hands and track down precisely what was happening.

As it turns out, the text going into Flickr is filled with new line indications that correspond to my email client’s limitations. These new lines then translate into an unusual short-width blog post on Flickr, though on the Flickr pages it looks just fine.

The real problem creeps up when Flickr then shoots the entry over to my WordPress blog for posting, where all of those new lines are replaced with HTML line breaks, and what then becomes rendered on my personal blog page is a hideous mess of text that breaks both at the end of the available page space as well as randomly throughout sentences!

There’s no way to fix this from the carrier/client-to-Flickr side of things (mind you, the Flickr staff may be able to implement a solution), so the best that we can do is to utilize our access to the WordPress side of things to write our own plugin to handle the resulting mess as best we can – and I’ve spent a few minutes this evening between travel and work to do just that. The result is Flickr Stripper.

Why is it called “Stripper”? Because that’s precisely what it does. It strips out all “\ n”’s and replaces them with “ “ (a space) so that there are no more random line breaks. Beyond that, it detects new paragraphs by searching for double “\ n”’s and replaces them with the HTML “< p >” tag.

Are there problems? Sure. It was written in very short order to do a quick and dirty job and, frankly, there’s only so much that one can do with the data that Flickr is passing through.

One such problem is that a genuine, bona fide new line can not be had. The plugin works great if you write in a general “full paragraph” by “full paragraph” style, but if you have text that you truly want to appear on new, single lines such as this:

This is one line.
And this is another line, with a single carriage return.
While this is a third.

You won’t be able to have it. The text will appear like this:

This is one line. And this is another line, with a single carriage return. While this is a third.

Unfortunately, the data does not give us any way to distinguish between bogus new lines and actual new lines. The only thing that we can truly detect are new paragraphs, as they give us clues by appearing as a double new line. So you can have this:

This is text in one paragraph. This is in fact the first paragraph, and in a moment you’ll be reading the second. The second paragraph will tell us that we can have as many paragraphs as we want, but that we’re limited in other formatting options.

This is the second paragraph. While we can have as many paragraphs as we want, we are limited in our formatting. For instance, we will not be able to have single new lines throughout our post. Paragraphs are all we have.

The third paragraph – this one here – tells us that thankfully, most posts of pictures and video via phone are unlikely to have anything but basic text anyhow, which means that for the most part, we’ve solved our problem.

Your mileage may vary based upon carrier and/or client. Users will undoubtedly discover their own idiosyncrasies, but the best bet is to just try it out and see if it works for you. It works great for me. The good news is that the code is extremely simple so adjustments to unique situations can be quickly made.

How To Setup Flickr Stripper

1.) Download the code here
2.) Unzip the file and place flickrzipper.php in your WordPress plugins directory as per usual.
3.) Activate the plugin via the Admin panel
4.) Setup your Flickr account to allow you to upload photos via email.
5.)In your Blog Layout (on Flickr), make sure that you use {description_raw} (the default is {description}, simply replace that with {description_raw}).
6.)Send a photo to your Flickr blog email address to test it out!

Feel free to leave comments, let us know if it worked for you or if it didn’t, and if you’d like to see something like this evolve into a more robust bit of code to support more options and scenarios. Who knows, I might just have a break in my schedule to make it happen.

###

tags: , , , , , ,

3 Responses to “Flickr Stripper Saves The Day”

  1. Rolf Says:

    This is what I’ve been looking for! I just tested the plugin, and it seems to work very well. Thank you very much!

    My only critical point would be that the script doesn’t close the HTML “p” tag at the end of the alinea, resulting in an invalid XHTML markup. I’m not a coder, so would it be possible to place the “/p” tag after “$content” in the “$content=eregi_replace(…);” line, or is it more complex than this?

    Once more, thanks for the great plugin!

  2. Keith Barrett Says:

    Ah yes. It’s the 21st Century and we are still plagued by a problem that has existed since the 1970’s — newline translation between different operating systems (mostly between Unix and Microsoft). Next I’ll be hearing that you can’t use an amperstand, “” character in your text because of HTML translation. ;-)

  3. Keith Barrett Says:

    (Not in the above comment, the “” actually contained a less-than sign and a greater-then sign — the comment parser failed to translate them into HTML :-)

Leave a Reply



Top incoming search terms for this post

 wordpress (12)  flickrstripper (3)  flickr stripper (3)  saves the day 2003 pictures (3)  computers internet blog (2)  flickr strippers (2)  html carriage return in flickr (1)  stripper of the day (1)  wordpress single carriage return (1)  all of my emails are showing paragraph code breaks how do i turn that off? (1)  flickr striper (1)  flickr staff (1)  flickr wordpress test post failed (1)  stripper official site (1)  jouporn forum (1)  new line return character stripper (1)  my first day as a stripper (1)  strippers on stage photos images (1)  download stripper on my cell phone (1)  i became a stripper for the day (1)  "stripper of the day" (1)  stripper wordpress (1)  stripper + translate (1)  STRIPPER STAGE (1)  "new line" flickr description (1)  flickr test post failed (1)  stripper stage pictures (1)  jouporn (1)  strippers codes for myspace (1)  c.b.c. stripper (1)