Fixing Flickr Thumbnail Photostream WordPress Plugin

September 12, 2011 | By Rakhitha | Filed in: Tech.

Flickr Thumbnails Photostream” is one of the neatest plugins available to display a random set of photos from a Flickr stream on your WordPress sidebar. I tried out so many plugins before settling with this one for my blog. It builds a local cache of information about your Flickr stream in your website database. As a result it performs faster.  Cache does not contain a copy of images. And the plugin is very simple and easy to customize. Which was the main selling point for me.

It’s a wonderful plugin, but it has some issues. Biggest of which is, when trying to update local cache from Flickr, it often times out if your stream has more than 50 images, which is common for many Flickr users.

If you have already used this plugin, you know what I am talking about. “Flickr Curl Function failed to execute. Oops, there seems to be a problem accessing the Flickr information.” is not a very helpful error message :). However in its community pages there is a partially working solution. With bit of time getting my hands dirty with PHP code. I managed to do a pretty much complete solution for the problem. And here it comes. By the way if you guys don’t want to mess with PHP or the plugin code of your sites, this is where to stop.


In this file, I have included two new functions. Nothing complicated. They are just there to format out HTML log messages that are written in to plugin admin page when updating local cache.

Then I also changed getResponseObject function to increase cURL connection timeout to 30 secs, and cURL time out to 6000 secs. This took care of most of the timeout issues.


In this file, I have changed all error messages to use HTML formatting functions I added above. In addition I have added some information messages to make updating process more transparent. With those you will be able to see all the images that are being loaded.

Following the partial solution given on community page,  I modified the code to load photo stream batch at a time instead of all at once. Batch size is hard coded to 25. This should pretty much get rid of  timeout issue. It will also get rid of 500 photos limit. But I have placed an artificial  500 photo limit in the code. Because it may be best to have only the recent 500 photos shown, if you have thousands of photos in your stream.

In case you guys are using this plugin and having problems with above issues, this might be useful. If you want to apply these changes to your blog, some technical knowledge will be required to edit the plugin file to replace them with code I have posted. Also other changes / plugins you may have in your sites might also conflict with these changes. Just Saying :).

Here is the code. You can find my specific changes if you search for ‘RAKA’ in the code.

[download id=”1″]



With further use and increasing number of photos in my stream, I discovered number of more problems.

1. This plugin store all it’s cache in one WordPress option. At one point it simply stopped caching my newly added photos. I checked option table and found that it uses a LONGTEXT column to store option values. Theoretically it can handle up-to 4Gb of data. But the real limit depends on the packet size being used in database connection as well as available memory. So it’s not that much, and gave me trouble once I have 130 images on this host.

I basically wrote a new update option function for arrays to handle arrays in a slightly different way. If array is longer than a specific number of elements, it will split it in to chunks and each chunk will be stored in a separate option. This will prevent pushing the luck against mysql packet size. This is still bad design. Ideally there should be a separate table for this cache.

2. When there is a large number of photos in the stream, it will result in a large number of calls to Flickr API. You might end-up being temporary blocked from accessing it either by firewalls at the host or  Flickr (Flickr says they don’t block so it must be firewalls).

To work around this. I wrote a separate script to download the photo cache in to a file in your local machine. And implemented a photo cache upload facility to ‘Flickr Control’ page.

Here is the modified plugin. Search for RAKA to find changes…

[download id=”2″]

Here is the script to download the data from Flickr to hard disk for uploading to the plugin. You will need to edit the script and provide your Flickr API Key and User ID.

[download id=”3″]


Tags: , , , , , , ,

5 comments on “Fixing Flickr Thumbnail Photostream WordPress Plugin

  1. Kelly says:


    I’ll try and have a look at what you’ve done here later this week.

  2. Rakhitha says:

    Thanks! Feel free free to take anything in to original code if you have access to it.

  3. Chris Hutchison says:

    Thank you!

  4. Hi Rakhitha.

    I just tried out the original plugin, but got those time-outs you talk about in this post, then I found this post and I wonder if you know if this plugin still works with WP 3.4 and if there is a way to add the Flickr photo size “Large Square” (150×150 px) to it. Looks like the original plugin is not under development anymore.


    • Rakhitha says:

      I currently using the plugin and it is working without much problems with latest word-press (upgraded last week). One thing I noticed is since this plugin uses wp-options to store image cache it may give you trouble if you have lot of images and there is little memory available in the server. Basically when that happen plugin will download images but it will not be saved in to your wp-options table so you will be still running with old cache.

      About getting other sizes of thumbnails.

      If you check runScript.php file you will find following block of code inside flickrScriptMain function. If you hardcode the value of $strSizeChoice variable to match with the name of that size you should be able to get the size you want. But if you want to include this as an option in the plugin settings page you will need to do little more changes.

      foreach ( $arrRspObjGetSize['sizes']['size'] as $value )
      if ( $value['label'] == $strSizeChoice )
      $strImageSrc = $value['source'];
      $strWidth = $value['width'];
      $strHeight = $value['height'];