Photo Blogging

Readers probably wouldn’t have taken much notice of the recent photo posts here and here on my site. The thing is though, these are a result of a bit of ingenious behind the scenes code that allows me to snap a picture with my BlackBerry camera and blog it in seconds thus allowing me to start a photo blog category that comprises of quick snippets with a photo for when a picture is more appropriate and I’m no where near a computer.

The real power behind this is Flickr but as those who know me will testify, I don’t like to use external services that take people away from my site, so I devised a way to bring the convenience of mobile Flickr uploads to my blog rather than to Flickr.

To begin with, the easy bit. I registered a Flickr account and installed the Flickr application on my BlackBerry. Now I can take a photo with the BlackBerry and send it to my Flickr photo stream with a title and a caption in a few seconds. Now comes the hard bit. Getting the stream on my blog and removing any Flickr artifacts along the way.

The saving grace here is that Flickr provides an RSS2 feed of any users photostream (so long as it’s set to public). In addition to this, there is a popular WordPress plugin called Feed WordPress that allows the syndication of RSS feeds onto your blog. I installed this plugin and subscribed to my Flickr feed with it. Now I was getting all photos posted to Flickr on my blog, I just had some cleaning up to do, and annoyingly, this is what took the time and effort.

Firstly Feed WordPress is designed to list all feeds coming into a blog as contributors so you can give appropriate credit. In my case though it was my own Flickr feed so I wanted to avoid this link category being shown on my site. To fix this I specifically excluded the category Feed WordPress had earmarked for contributors by specifying it in the arguments of the theme function that displays the links list. Users who are using a theme with widgets or who haven’t customised their site as much as I have might be able to use widgets to do this.

Secondly I had to change some Feed WordPress settings to get perfect operation. Mainly forcing all “posts” from Flickr to go into my Photo Blog category and also to ensure that all these would be attributed to my username. I also entered the default Flickr e-mail address,, as an allowed user such that my Flickr entries would be syndicated without going through moderation. This would be a security risk if I wasn’t the only person who could add feeds to my syndication list or post to feeds already earmarked for syndication but as neither of these situations are true its ok.

Finally I needed to ensure that the actual body of the post appearing on my site showed the proper content. By proper content I mean a good sized image, linked to the original and showing nothing else alongside it but the caption and no reference to Flickr.

To do this I used a custom code modification to Feed WordPress which would extract the true location of the picture in the Flickr feed and store it as an attribute of the post. For those wishing to replicate what I have done here, the code below needs to be entered inside the SyndicatedPost class, at around line 1100 in the feedwordpress.php file of the Feed WordPress plugin.

if (isset($this->item['']['content@url'])) :
$this->post['meta']['flickr_original_image'] = $this->item['']['content@url'];

In addition to the Feed WordPress modification I also added a plugin hook that would parse the content of all posts in the Photo Blog category in order to retrieve the image location stored with the above code, correctly display it and to parse the remaining text for the caption thus remove references to Flickr. In the code below the number 36 refers to the id of my Photo Blog category.

Plugin Name: Fix Flickr Posts
Plugin URI:
Description: This plugin removes cruft from the posts imported from flickr
Author: Kieran O'Shea
Author URI:
Version: 1.0

// Apply function to remove content from posts in the correct category
function fixFlickr($content) {
global $post;

$first_cat_id = get_the_category($post->ID);
$first_cat_id = $first_cat_id[0];
$first_cat_id = $first_cat_id->cat_ID;

$flickr_image = get_post_custom($post->ID);
$flickr_image = $flickr_image['flickr_original_image'][0];

if ($first_cat_id == 36)
$photo_bit = '<a href="'.$flickr_image.'"><img src="'.$flickr_image.'" width="450" alt="'.$post->post_title.'" border="0" /></a>';
$pwned = explode('<p>',$content);
$pwned = $pwned[3];
$text_bit = '<p>'.$pwned;
$content = $text_bit.'<div style="text-align:center;border:0;">'.$photo_bit.'</div>';
return $content;

// Add filter to the_content
add_filter('the_content', 'fixFlickr');
add_filter('the_excerpt', 'fixFlickr');
add_filter('the_content_rss', 'fixFlickr');
add_filter('the_excerpt_rss', 'fixFlickr');

And there we have it, my own photo blog that leverages power from the Flickr system but which displays in my own way on my own site. If you want to try this by all means test out the above method and code but I must stress that this method is unsupported by me or anyone else. If you try it and get it to work, please comment below. It is worth noting that any phone with a camera and a Flickr upload program designed for it will work in place of a BlackBerry. To all that succeed with this method, happy photo blogging!


Possibly related articles


  1. murphythadog Said,

    May 6, 2009 @ 9:01 pm

    Nice post. I’ve been playing around with my Storm as well. I go to Blues and Brews every Friday and try to get a shot or two, and then I take a few pics of the band as well 🙂

    I was uploading some of my stuff to Twitter and MySpace but some of the pics are rotated. Does Flickr auto rotate images directly from the device?

  2. Kieran Said,

    May 8, 2009 @ 7:12 am

    Rotation is an issue. I have to take all my BlackBerry photos in landscape in order for the above to work.

RSS feed for comments on this post