Sunday, August 30, 2009

Flickr RSS Feeds. Too big, too small

Read More

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 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 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:



<?php
date_default_timezone_set('UTC');
$uri="";
$first_var = "1";
foreach($_GET as $variable => $value)
{
if ($variable == 'uri')
{
$uri = $uri . $value;
}
else
{
$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("_s.jpg","_m.jpg",$data1);
$data1=str_replace('height="75"', "",$data1);
$data1=str_replace('width="75"', "",$data1);
echo $data1;
echo curl_error($ch);
curl_close($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 <> tags in the file to <>.


So if your feed URL was this:

http://api.flickr.com/services/feeds/photos_public.gne?id=8575807@N07&lang=en-us&format=rss_200


Use this instead

http://YourBlogUrl/FlickrRSS.php?uri=http://api.flickr.com/services/feeds/photos_public.gne?id=8575807@N07&lang=en-us&format=rss_200


This will change the tag to point to the lager sized image, so your slideshows will load quickly, and look nicer :)



Sunday, August 02, 2009

Cool technology

Read More

Six and mean

Lilly came in to my office the other day. “Dad I have to go out now. Can you get the TV to record my favourite show in an hour”.


“Hmmmm????”, I replied in typical pre-occuipied father mode.


But she had an intensity in her eye that made me realize I ignored this six year old at my peril, despite my displike of leaving my desk while in the middle of solving a problem.


Happily, I didn’t have to get up from my chair. I just logged in to IceTV, found the program she was interested in, and told my PVR to record it via the website.  My PVR is a High-Definition Beyonwiz DP-S1. It’s wireless, but I’ve wired it in to the house LAN so we can watch movies from our D-Link DNS323 1TB NAS


We also have an older Topfield 5000 PVRT.  It’s only standard definition, but the cool thing about it is that it has an open programming interfacem , so a lot of people have written their own software to get it to do cool things.  One application I added to it was ToppyPC by John De Angelis.  It has a program called “TWIN” which adds a web page to your Topfield PVR.  So you can set timers, and record shows, like IceTV lets you do with the Beyonwiz.   ToppyPC needs another utility to run – an FTP server (ftp4t by Aldarin) which runs on a PC which I connect to the Topfield via a USB cable.


All this technology is both good and bad. It’s convenient, but I don’t get the exercise I need going up and down stairs to program the PVR!


But at least I don’t have an angry six-year-old to contend with!