Slideshow from RSS for WordPress


In this article about using slideshows in wordpress I showed you how to embed slideshows in WordPress blog posts and sidebars using the Google Ajax Feed API.

I prefer to use this facility to pull in Image feeds from Flickr.

The problem with the images in these feeds is that they’re either too large or too small.

The MediaRSS specification has a <media:thumbnail> tag which lets you have a thumbnail image in your feed. That’s great, but the image size of the thumbnail is 75×75 pixels, which is useless for a nice looking slideshow. It ends up looking terribly blurry with no detail.

The Google Ajax Feeds API tries to get around this by letting you specify a “thumbnailTag” in the slideshow options object. Basically, you set this to “content” to tell the API to look for the image in the “content” section of the feed, rather than the <media:thumnail> section. This is also great, but the problem is that Flickr uses the LARGE (or even worse, ORIGINAL) image size in this section. So you get nice large detailed images in the feed, but they’re so large that they take ages to load, and your slideshow sits there for ages saying “Loading….” while it grabs the huge images and chews up your audiences bandwidth.

So I wrote a simple PHP screen scraping utility which grabs the Flickr feed, and changes the ImageUrl…_L.jpg to ImageUrl….M.jpg – in other words, it modifies the feed to include the medium size image rather than the large size.

Medium sized images are fine for slideshows, and they load quite quickly.

Here’s the PHP code:

$first_var = "1";
foreach($_GET as $variable => $value)
if ($variable == 'uri')
$uri = $uri . $value;
$uri = $uri . "&" . $variable . "=" . $value;
header("Content-Type: application/xml; charset=ISO-8859-1");
$ch = curl_init() or die(curl_error());
curl_setopt($ch, CURLOPT_URL,$uri);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data1=curl_exec($ch) or die(curl_error());
$data1=str_replace('height="75"', "",$data1);
$data1=str_replace('width="75"', "",$data1);
echo $data1;
echo curl_error($ch);

Just save this in a file named FlickrRSS.php in the top folder of your wordpress directory. Then instead of using your flickr RSS feed, pass the feed as a query parameter to the PHP utility.

You’ll need to change the &lt; and &gt; tags in the file to < and >.

So if your feed URL was this:

Use this instead

This will change the <media:thumbnail> tag to point to the lager sized image, so your slideshows will load quickly, and look nicer 🙂

Welcome to the new TechMusings Blog

I recently moved this blog from Blogger to WordPress.

The old blog was at

I’m still trying to come to grips with WordPress.  Somethings in Blogger were much easier (such as slideshows), but I think WordPress looks much nicer.

Please let me know what you think, and if you’ve got some suggestions, I’d really like to hear them.

Schizophreinc Blogs!

I have a schizophrenic blog. Some days I upload copies of postcards that I receive. Other days it’s info about migration to Australia in the 60’s. And then it might be some photos of family and friends.

So it’s a bit of a mixed bag.

Which is fine by me. My attention gets pulled all over the place, and I get interested in lots of different things. A bit like Homer Simpson walking through a shopping mall 🙂

But it could make life hard for my readers, so I recently added a little Javascript widget that makes the blog change its appearance depending on what interests you. Coupled with judicious use of blogger labels, it works wonders.

It’s the same blog, but it changes shape depending on how you get to it.

Have a look at these two different links to see what I mean.

First if you’re interested in Postcards go to the blog via the URL:

Second if you’re interested in Ten Pound Poms go to the blog via the URL:

(Hint for the uninitiated “Ten Pound Poms” were migrants who came to Australia from Britain between 1950 and 1971).

There are two cool bits to this.

The first is that you get a totally different set of links at the top of the blog depending on how you view it. I do this by adding some query string parameters to the URL. (The “?pcd=1” or “?tpp=1” parts of the URL).

Secondly, using labels in the URL lets me control what articles appear when you visit. (That’s what the “/search/label/…” bit of the URL is all about).

You might think using query strings on your URL is a messy way to get to your blog. But it’s really easy to set up a domain and (using something like ZoneEdit’s “webforward”) point that domain to a more complex URL.

For example, and both point to the same blog, but I’ve used ZoneEdit to add different parameters to the URL query string.

A small Javascript widget at the top of the blog looks at the query string, and decides what sort of links to display. Basically it’s saying “If you’ve come here to look at postcards, I’ll show you some postcard links. But if you’re interested in Ten Pound Poms, then I’ll show you some different links instead.

Here’s the code. The Orange section is a javascript function to pull the query parameter out of a url. The Green section controls what gets displayed when people are interested in “Ten Pound Poms”. The Blue section is what gets displayed when people are interested in “Postcards”.

function gup( name ){ name = name.replace(/[\[]/,”\\\[“).replace(/[\]]/,”\\\]”); var regexS = “[\\?&]”+name+”=([^&#]*)”; var regex = new RegExp( regexS ); var results = regex.exec( window.location.href ); if( results == null ) return “”; else return results[1];}

var tpp_param = gup( ‘tpp’ );
var pcd_param = gup( ‘pcd’ );
if(window.location.href == ‘’)
      tpp_param = ‘1’;
if(window.location.href == ‘’)
      pcd_param = ‘1’;
if(tpp_param == ‘1’)
      document.write(‘<div id=”tpp-info” class=”sidebar section”>’);
      document.write(‘<h2 class=”title”>Ten Pound Poms</h2>’);
      document.write(‘<a href=”″>Home</a> Ten Pound Poms | ‘);
      document.write(‘<a href=”″>About</a> Ten Pound Poms | ‘);
      document.write(‘<a href=”″>Links</a> for Ten Pound Poms<br/>’);
      document.write(‘<a href=”″>Migrant Ships</a> – How we got here<br/>’);
      document.write(‘<a href=””>Musings</a> – Back to the main blog’);

else if(pcd_param == ‘1’)
      document.write(‘<div id=”pcd-info” class=”sidebar section”>’);
      document.write(‘<h2 class=”title”>My Postcards</h2>’);
      document.write(‘<a href=”″>Home</a> – My Postcard Blog | ‘);
      document.write(‘<a href=”″>About</a> My Postcards | ‘);
      document.write(‘My Postcrossing <a href=”” target=”_blank”>Profile</a><br/>’);
      document.write(‘<a href=”” target=”_blank”>Postcrossing</a> – A great way to send and receive postcards<br/>’);
      document.write(‘<a href=”” target=”_blank”>Postcard Collection</a> at Flickr<br/>’);
      document.write(‘<a href=””>Musings</a> – Back to the main blog’);