They provide easy ways to integrate PicLens into your site, including the wp-piclens plugin for WordPress. But there’s a snag. Out of the box, at least for me with my WordPress 2.3.3 installation, it only works properly when pretty permalinks turned off. (That means
http://home.toastboy.co.uk/?p=123 style links would work, but not my preferred
http://home.toastboy.co.uk/2008/03/09/sample-post/ ones). The way it would fail is that when you click on the “Start Slide Show with PicLens Lite” link which the plugin helpfully inserts into posts which have images in them, PicLens opens up but sits there forever with a “loading” progress bar, not getting anywhere.
Time to break out the debugging chops :->
It turns out that PicLens was actually getting a 404 error when it requested the Media RSS feed from
wp-content/plugins/wp-piclens/mrss.php. Weird, since when you request the feed directly, you’d be confused to see that the feed actually appears – but sure enough, look at the headers with Live HTTP Headers, and the response code is a nasty 404 instead of the nice 200 we might expect. This is caused by the way that wp-piclens invokes the wp() function to generate the MediaRSS. To cut a long story short, the WordPress parse_request function assumes that when URI rewriting is turned on, it’s going to generate a 404 error. Then, if and only if it finds a rewrite rule to successfully apply, it resets that error. So, despite the fact that the URI for the MediaRSS feed doesn’t actually need rewriting, you get a 404 error when you request it when URI rewriting is turned on. The fix? Add a hook in the plugin to rewrite the mrss.php URI onto itself, like this:
$feed_rules = array( 'wp-content/plugins/wp-piclens/mrss.php' => 'wp-content/plugins/wp-piclens/mrss.php' );
$wp_rewrite->rules = $feed_rules + $wp_rewrite->rules;
Then you need to force the rules to be re-generated: go to Options/Permalinks in your WordPress dashboard, select “Default” and hit “Update Permalink Structure”, then re-select your preferred permalink method (mine is “Date and name based”) followed by another “Update Permalink Structure”.
That should be it! Now when you click on the “Start Slide Show with PicLens Lite” link, you should see your photos on the PicLens wall in all their glory.
(Now I can finally get on with adding some content instead of fiddling with infrastructure… maybe…)