random flickr favourite

If you use and like this plugin, please make a donation in form of a link from your site to my blog. Thanks.

With this wordpress plugin (now version 2.1.2, updated 23.01.2008) you can dispay an image randomy selected from your or any other persons favourites at flickr.com.

  • Usage
  • Features
  • History
  • Donate
  • Download
  • Requested Features
  • Seen at
  • Usage

    Usage is really simple: Yust download, install, activate and place the following code anywhere:

    <?php if (function_exists('RandomFlickrFav')) { 

    Then go to the admin’s menu and enter the url of your favourites at flickr.

    For further configurations just go to your admin menu’s options and there to RandomFlickrFav.


  • Synchronization with your favourites at flickr.com in predefined intervalls
  • Fast plugin, stores all neccesary information in a db table
  • Simple template driven layout
  • Own administration page
  • Tested with WP 1.5.2, 2.0.5, 2.1.3, 2.3.1, 2.6, 2.7, 2.8, 2.9 (up to 2.9.1)
  • Hint: When copy-pasting code from this page, some asian (and perhaps other non-latin character language) versions of operatingsystems may have problems with characters. In this case just retype the code by hand. (Thanks to Justso for this hint)


    Changes from 2.12:

  • Regex for ripping the image-urls from flickr, since they changed it.
  • Function to clean DB-entries, helpful while debuging.
  • Debug output can be seen as HTML on configurationpage.
  • Name of image-author is beeing ripped from URL.
  • Changes from 2.11:

  • I just changed the regex for ripping the image-urls from flickr, since they changed it.
  • Changes from 2.0:

  • I just optimized some of the code and removed a bug, which was not visible to the user.
  • Donate

    If you like this plugin and it helps so much, that you would like to donate (no matter how much), please do it here.


    Download here V2.1.2 (23.01.2008)

    Requested Features

  • Manage multiple favourite urls at flickr (suggested by nolageek)
  • Enable multiple random images from the plugin (suggested by sindhu and Anonymous)
  • Check the behaviour with very large collections (> 500) (reported by Hugo)
  • More debugging information
  • Check if the plugin also runs with other sets (Home set etc.) (suggested by Chris P.)
  • Enable / Disable UTF-8, or better use WP default encoding
  • Integrate Lightbox Script (suggested by Anonymous)
  • Automatic update of the regular expressions used when flick changes pagelayout
  • Rip tags of the images and store in database for further use

  • Any suggestions? – Make a post !

    Seen at

  • Devlounge.net article about customizing wordpress layout
  • Justso’s chinese homepage
  • Nolageek’s personal blog
  • fooo.info
  • mondoblog.it collection of flickr plugins
  • John’s clearcutblogging.com with an interresting article about including this plugin per post
  • 56 Responses to “random flickr favourite” »»

    1. Comment by Christian | 16:52 06.01.06|X

      I use WP 1.5 copied RandomFlickrFavs.php to the plugins directory, but it did not appear in the Manage Plugins page. What’s wrong?

    2. Comment by Secco | 14:26 07.01.06|X

      You should enshure, that the php-file is placed in the folder wp-content/plugins/
      Also don’t forget to upload that plugin in ascii mode. Then enshure, that you set the filepermissions (rwx for owner and group, r for world). To set filepermissions you can use your ftp-client (eg. leechftp) or a telnet account and the command chmod. Then the plugin should appear in the plgin management of wp-admin.
      My wp has version 1.5.2, so perhaps there are some incompatibilites to 1.5, which I haven’t tested.
      If you installed it the right way and it still makes problems, then let me know.

    3. Comment by Secco | 8:53 10.01.06|X

      There is a new issue with the urls for the images: Flicker refers to RSScache.com with the text „Please use RSScache.com“. Since I’m deeply involved in a project and have no time for my script, you will have to wait at least one week for a new running version of this plugin. Sorry.

    4. Comment by Secco | 14:44 10.01.06|X

      The rsscache.com stuff is less bad as I thought. You just have to use a different url for the plugin to work. My new url is „http://my.rsscache.com/flickrate.gasteroprod.com/feeds/favorites/95202115@N00/rss/“. So the plugin still works :)
      But I think it would be nice to have some local caching of images to avoid trafic to flickr.com.

    5. Comment by Secco | 21:40 11.01.06|X

      Either rsscache or flickr have changed the layout of the delivered rss feed. This means that the plugin again doesn’t work properly. I have to change the code to enable the new format. Well, perhaps I can do that within this week. Stay tuned.

    6. Comment by Secco | 13:28 10.03.06|X

      Now flickrate.com is down and there are no rss feeds available for flickr.com. I’m working on a dirty-hack version of RandomFlickrFavs, which will scan the favourites pages and extract all links. Since this is quite time and traffic affording, I will add an image-cache to the plugin, which will store requested images of Flickr.com into a local cache file. This should also avoid too much traffic to Flickr.com.
      At which time the plugin will be available, I can’t tell. I’m working on it at my short spare time.
      If you want to support me, just let me know you want that plugin :)

    7. Comment by Secco | 17:51 13.03.06|X

      The beta of RandomFlickrFavorite2 is now finished and I’m testing it. In a couple of days it should be ready for publishing.

    8. Comment by Secco | 22:48 13.03.06|X

      The actual version of 2.0 is now finished. For the next version I’ll perhaps add some RSS-Feed for your favourites. For any functional requests just write.

    9. Comment by Pim | 20:23 23.03.06|X

      Is the posted code correct?

      If I look at your page source, it has an debug entry in it, like you mention in the admin page.
      I don’t get any output at all at my own wp install.

      Plugin is activated and the images are loaded (191!).

      What is going wrong?

      Thx for your time

    10. Comment by Secco | 13:11 24.03.06|X

      Yes, the code work’s fine. The debug messages are placed in the html output, as a comment. While I was testing on my blog, I didn’t want the visitors to see the debug messages. Just enable debug and look at the page-sourcecode. You will find a commented block with all debug messages.
      By the way: please take the time to write some comments / suggestions / make a vote on the poll. I’ve got several hundreds of downloads but no response…

    11. Comment by Maxell | 2:33 05.04.06|X

      Hello! Cool blog, interesting information! Great work, very useful. Thanks you!

    12. Comment by Brittany | 0:59 29.04.06|X

      Im getting an error message for line 473….

      Warning: Invalid argument supplied for foreach() in
      blahblahblah/RandomFlickrFavs2.php on line 473

      473 says…

      foreach ($RandomFlickrFavs_image_ids as $a_image_id){

    13. Comment by Secco | 8:28 02.05.06|X

      I would need some more details. Could you enable the debugging option of the plugin and look at the generated pages sourcecode for a comment block, which contains the debugging information?

    14. Comment by Chris P. | 13:18 17.06.06|X

      Hi Secco

      I’ve installed the plugin, copied my RSS feed URL into the configuration page, turned on debug, and saved. When I force a synchronize, nothing appears. I have the php code in my home page, yet no info is generated.

      If the plugin is locally caching the photos, where is trying to put them (e.g. directory) and what permissions should I have on it?

      I am getting no errors or anything. Plugin is activated fine.


    15. Comment by Chris P. | 13:39 17.06.06|X

      Ok. I was being dumb. Didn’t have any favourites in place. Can I use this for other Flickr sets? e.g. my home rss feed?

    16. Comment by Secco | 9:24 19.06.06|X

      The plugin, for now, doesn’t support any rss feeds. It dumply browses all of your favourite pages and ripps the links to the images (by excessive use of regular expressions).
      You can enter any url that leads to a page containing images like your favourites, but I just haven’t tested it on other flickr pages.
      By the way: Are there any rss feeds for flickr favourites / photos at flickr? I couldn’t get any.

    17. Comment by Hugo | 21:14 25.07.06|X

      Hello, i’m trying this plug and works fine with the default account.
      But when config with my account and click on „update from flickr“ prints this on screen and don’t load the images:

      Fatal error: Maximum execution time of 30 seconds exceeded in \wp-includes\class-snoopy.php on line 901

      I have 1,883 photos marked as faves, could be the problem by this?

    18. Comment by Secco | 14:37 26.07.06|X

      Hmm, yes this could be the problem. It looks like the snoopy (the php http client) has a timeout while trying to get the contents of your favourites sites. you should have a look at the class-snoopy.php and / or look for information about configuring that class. You should try to set the timeout to a higher value, eg 1-2 minutes.
      But that’s unusual, since the pugin rips the image information page by page and thus should have no problem with a bigger amount of favourites. Perhaps the network-connection between the server, that’s running the plugin and the flickr pages is not fast enough or the flickr pages are overloaded or block your server that does several hundreds requests to get all of your favourites.
      For now, I can’t realy help you out of this.

    19. Comment by Hugo | 16:15 26.07.06|X

      OK, thanks for your time and I will try to set the timeout to a higher value.

    20. Comment by Scott | 18:17 09.09.06|X

      Ive added the code within my theme template (this doesn’t need to be within the loop, right?), activated the plugin, added a favorites url, and verfiied that there are images in the database. However, nothing is outputted…if you check out the source of the webpage http://godevils.org/archives/1, you’ll find an empty div called „sdlaws“ where the php call is located. Any ideas?

    21. Comment by Secco | 11:40 10.09.06|X

      First (what you shurely did), enshure that the plugin is activated.
      Then go to the admin page for the plugin (Options/RandomFlickrFav) and enshure, that you have entered the correct url for your favourites. If there is no such administration option, you didn’t activate the plugin or the activation failed.
      On the administration, you can click on the „Synchronize now with flickr.com“, to enshure, the plugin got all of your favourites.
      After all, you can activate the debug option on the admin page, so you will get lots of debug-information at the place, where your empty div tag is located at. At least that debug information could help you and me, to find out, what’s going wrong.

    22. Comment by Shiva | 8:32 22.11.06|X

      Hello. Great work on the plugin! I am trying to integrate this plugin with my site but no images are being loaded. The plugin is definitely enabled and it is picking up my favorites (I can see them in the admin panel).

      I am not using the standard wordpress index.php but creating one. I have this at the top:

      this picks up other plugins/functions fine but it does not seem to pick up randomflickrfave. I have this in the body to call it:

      I get nothing there and if I add an „else echo ‚no'“, this will echo onto the page so it is clearly not reading the function. How can I call this function?
      thanks for any help!

    23. Comment by Shiva | 17:43 22.11.06|X

      Hi My earlier post got messed up and its not displaying bits of code I pasted in..here it is again:

      Hello. Great work on the plugin! I am trying to integrate this plugin with my site but no images are being loaded. The plugin is definitely enabled and it is picking up my favorites (I can see them in the admin panel).

      I am not using the standard WordPress index.php but creating one. I have this at the top(I took out the brackets to make it readable here):

      /* Short and sweet */
      define(‚WP_USE_THEMES‘, false);

      this picks up other plugins/functions fine but it does not seem to pick up randomflickrfave. I have this in the body to call it

      But no photos and if I add an “else echo ‘no’”, this will echo onto the page so it is clearly not reading the function. How can I call this function?
      thanks for any help!

    24. Comment by Secco | 20:25 22.11.06|X

      Hi shiva, sorry for needing so long. As I’m quiet bussy, I can only approve the comments in about 2-3 days.

      I am not using the standard WordPress index.php but creating one.

      Hmm, that doesn’t sound familiar to me. So I would need more details to help you.
      But if you’re enough familiar to php, that you modify your wordpress, you shurely should be able to have a look at the plugin’s source.
      Another help could be the debug-functionality of the plugin. When you enable debugging in the admin panel, it should show you a lot of debug information within the sourcecode of the generated (blog-) page. It’s placed within a comment tag, so you’ll have to take a look at the pagesource.

      this picks up other plugins/functions fine but it does not seem to pick up randomflickrfave. I have this in the body to call it

      Well, when I first wrote the plugin I had many problems to integrate it as an usual plugin, so I took an working example and used the „if( !function_exists( ‚RandomFlickrFavs_get_option‘ ) ){“ very extensively. Perhaps the problem results from there and the plugin isn’t registered properly at the hooks.

    25. Comment by sindhu | 8:06 30.11.06|X

      hi there! this is the plugin i was searching for so long! thank you so much, may god bless you for writing this.

      but ive a suggestion to make: maybe you a option to show number of random images? like say 2 or 4 ? that would be nice and they can be displayed even in the header as well :)

      k then, chao

    26. Comment by Secco | 14:54 30.11.06|X

      Thanks for your compliments, sindhu. At moment I’m quite bussy, but when I have more free time, I will make some modifications to the plugin. For this purpose you can enter some feature request.

      a option to show number of random images

      I’m not shure, what this feature shall do? Suggest you configure to use 2 images. What shall be done with both images? You could place the call of the plugin at two places, which should result in two different images, and you can place the plugin also in the header. There is no restrictino about that.

    27. Comment by Justso | 17:13 03.12.06|X

      Hi, I’ve set up all right, insert below code into the header.php of my theme:

      and I can see the photos all being load to db from this page wp-admin/options-general.php?page=RandomFlickrFavs2.php,

      but I can not see any image by such template which is prompted in wp admin -> Options -> RandomFlickrFav


      how can I do with it now?

    28. Comment by Secco | 9:05 04.12.06|X

      hi justso,
      usually it’s enough to post once. Since I approve comments by hand, it takes some time for them to appear here.
      I had a look at your page and saw what you mean.
      You don’t have to put the template on your page. you have to include the php in your page:

      <div id=“polaroid“>
      <div id=“polaroidimage“>
      <?php if (function_exists(âRandomFlickrFavâ)) {RandomFlickrFav();}?>
      <div id=“polaroidcaption“><p></p></div>

      That php function will use the template you have configured in the Options->RandomFlickrFavs Page. So the template is configured on the admin page and used by the function.

      Hope I could help you.

    29. Comment by Justso | 16:44 04.12.06|X

      I finnally find what is wrong, the comma!!
      the inverted comma in beginning of this page is not right one for php, after I change it to right one, all run well

      I write two kind of comma into this file http://justso.cn/wrong_comma.txt
      please see it in utf-8

    30. Comment by Justso | 10:46 05.12.06|X

      I DO not know why, but Secco, I am sorry, but please delete XXXII comment, your page transfer single byte inverted comma into double byte…. I can not write it here

    31. Comment by Secco | 17:28 05.12.06|X

      Hmm, my page should use standard UTF-8. I guess the problem should be some different browsersettings from Germany to China. Well, who knows..
      Best way is typing the code-snipplet from above by hands.

    32. Comment by nolageek | 10:08 17.12.06|X

      LOVE LOVE LOVE this plugin. Does it cache the images on the local server or something when it syncs? Just wondering.

      Also, would it be possible to somehow set it to show multiple flickr favorites… ? almost like having an RSS feed, since flickr doesn’t have a RSS feed for favorites.. which is totally lame. Maybe show x number of favorites, configurable in the Options menu.

    33. Comment by Secco | 17:39 17.12.06|X

      hi nolageek,
      thanks you for your compliment.
      the images are not cached localy, since i’m not shure, if this would violoate some copyrights. the only things that are cached are the meta-informations of the images, like author, imagename, link to images etc.
      the idea of managing mulitple favourites is a good idea. the next time, i’ve time to make some advances, i’ll give it a try.

    34. Comment by Anonymous | 20:57 18.12.06|X


      Another Flickr plugin is really cool in the thumbnails and the lightbox script, u should include that in ur plugin *looks at u, hope in her eyes* =)

      and please do tell me how do i make ur plugin show up multiple random pictures. thankx

    35. Comment by Secco | 12:33 19.12.06|X

      and please do tell me how do i make ur plugin show up multiple random pictures.

      Well, this plugin isn’t really designed for multiple pictures. You can add the

      <?php if (function_exists(âRandomFlickrFavâ)) {

      twice on your page. But this will not guarantee, that the two pictures will be disjunct, since every call will generate one randomly and that can (although this would be unlikely) be the same again.

      I’ll take it on my TODO list.

      the lightbox script

      Well, I’ll have a look at that script. But that’s not so neccessary, since you can include your image within a table, which is surrounded by some border, like on the page you sent to me.
      For exmaple Justso from http://justso.cn uses this plugin at the top left of his page with a fantastic selfmade border around it.

      *looks at u, hope in her eyes*

      my girlfriend does the same, and usually is very successfull…

    36. Comment by Secco | 13:22 19.12.06|X

      Well, I had a look at the Lightbox Scripts and now know what you meant. It’s very pretty. I’ll add it on my TODO list.

    37. Comment by Anonymous | 17:48 21.12.06|X

      hmmmm it stopped working this morning. anyone else?

      RandomFlickrFavs_init with debug: 1
      RandomFlickrFavs_table_name: wp_randomflickrfavs
      found 1 image ids
      1 ids in cache
      size before return: 1 ids in cache
      random: 318
      RandomFlickrFavs_get_option(layout):This page will give you one picture from my flickr favorites list which is comprised primarily of guys that I don\’t know but think are cute. Yes, this is like, totally gay of me but really.. what did you expect?
      Click picture to refresh%%image_title by %%artist.


    38. Comment by nolageek here (up there) | 17:49 21.12.06|X

      didnt sign in above

    39. Comment by Secco | 9:03 22.12.06|X

      Well, anonymous, your’re right, it seems, like flickr has changes something on their page and thus the plugin can’t rip the images properly.
      I’ll have a look at it and find out, what the problem is.

    40. Comment by Secco | 9:11 22.12.06|X

      I think I found it. Flickr has changed the urls to the images from something like

      so the regex don’t work proper now.

      I corrected it in the now actual version 2.1.1, but you can also do it yourself:
      find the place, where it says

      preg_match(„/<a[^>]*?href=\“\/photos\/(.*?)\“.*?title=\“from (.*?)\“.*?<img.*?src=\“http:\/\/static.flickr.com\/(.*?)_s.jpg\“/ims“, $a_link[1], $single_image_data);

      and replace it with

      preg_match(„/<a[^>]*?href=\“\/photos\/(.*?)\“.*?title=\“from (.*?)\“.*?<img.*?src=\“http:\/\/.*?static.flickr.com\/(.*?)_s.jpg\“/ims“, $a_link[1], $single_image_data);

      (there is an additional .*? in front of the static.flickr.com)

    41. Comment by Vincent | 9:44 25.12.06|X

      that did it! THanks!

    42. Comment by Justso | 4:49 21.03.07|X

      Sooooo lovely Secco~~~~!!! after my installation of this plugin, I still had such problem, that I can not synchronize from my flickr~~ ,today I rewrite the code with the url come to farm1… , all things become right, thx~~~

      and tell you a bad news, I have to copy the wrong “ ” from here to my windows xp clip board, it is still double bytes character, so I think it is same to other chinese, japanese or korean, give this little tip avoiding that error

    43. Comment by fooo | 15:50 24.08.07|X

      I ‚am Guillaume, webadmin of http://www.fooo.info.
      I no longer use random flickr favorite because i am reworking my template, but i must say that i really enjoyed this plugin, and i hope many wordpress users will give it a try 😉

      Thanks for your hard work on this plugin, which will be back soon on my site 😉

    44. Comment by Volker | 11:21 06.09.07|X

      if the php function fsockopen is disabled, this plugin could not be used, because it uses the class-snoopy.php(which uses fsockopen). I asume that therefore in the Theme the RandomFlickrFav Function is always unavailable. The Option existing and could be changed, but each time the link sync with flickr is pressed, the security issue blocks any attempt to fetch data.

    45. Comment by John | 20:39 25.09.07|X


      I have been messing around with your plugin and I love it. I have created a cool way to set it up within a post. Perhaps we could work together to put this into the plugin. You can check the latest posts on my site to see what I am talking about.

      Best regards,


    46. Comment by Secco | 12:43 26.09.07|X

      Hi John, I had a look at your posts. That looks fine! I just included your article in the list of articles about this plugin.
      Of course we can work together to include more functionality in this plugin. But for that I would need a more concrete description of how you think we can improve the plugin.

    47. Comment by John | 15:02 26.09.07|X

      I was thinking something useful, especially for newcomers to using blogs, would be to have the option of having it embedded within a post like I did, without having to go through the work. The style sheet options would be set up as variables and they could change them within the drop down panel. Maybe even adding the Google ads to it as well. I will look at a plugin that kinda does what I am saying (injects something into a post) and see perhaps how it could fit. I haven’t made any plugins, but I think I am on the cusp of needing to be able to create or adapt them myself. So maybe you could help me along in this first project!



    48. Comment by Secco | 13:07 23.01.08|X

      As today flickr changed their favourites-page layout again, I’ll have to improve the plugin again. The actual version will be available as soon as possible.

    49. Comment by Secco | 14:08 23.01.08|X

      Problem solved. Just use the actual version of this plugin from the download link.

    50. Comment by dedits | 3:31 28.11.08|X

      Nice post man i just signed up to flickr to!

    51. Comment by morreene | 0:38 10.02.09|X

      Thanks for the plug-in. It works for me, but the I cannot set the parameters in WP settings. the link doesn’t work.

      By the way, can you add the feature of taking photos from specific tag or tags?


    52. Comment by Secco | 20:52 11.02.09|X

      Hi morreene,

      but the I cannot set the parameters in WP settings. the link doesn’t work.

      Could you describe that problem more precisely?
      By the way, what version of WordPRess do you use?

      can you add the feature of taking photos from specific tag or tags?

      I’m not shure, if that’s possible. Other than other Flickr plugins, RandomFlickrFav doesn’t log into your account and also doesn’t use flickr provided APIs. The only thing this plugin does is call your (public) favourites site and rip all of the images that are shown there. So the only information available to this plugin is the information provided on the pages of your favourites.
      The only possibility for this plugin to get the tags of the images would be loading the page of each image and rip the tags from there. I guess this can be done, but will take me lots of time.
      I’ll add it to the feature-wish list.

    53. Comment by kodama | 2:50 22.02.09|X

      I think I may be having the same problem as morreene: in WordPress 2.7.1, when I click on „RandomFlickrFav“ under „Settings“, I get the error:

      The requested URL /wp-admin/RandomFlickerFavs2.php was not found on this server.

      I’m not particularly handy with code, so I tried to see in the RandomFlickerFavs2.php where it was looking in wp-admin and redirect it to the plugin folder, but didn’t have any luck (i’m not even sure that this was the right way to go about it, or not). I also tried putting a copy of RandomFlickerFavs2.php in the wp-admin folder, but that just gave me a blank white screen when clicking on „RandomFlickrFav“ under „Settings“.

    54. Comment by Secco | 12:54 22.02.09|X

      Hmm, I don’t think it’s a problem of the plugin itself. I’m using the most recent WP release, too.
      The link under Settings should go to „wp-admin/options-general.php?page=RandomFlickrFavs2.php“.
      There is no need to put the plugin php into wp-admin folder. The link should call the „options-general.php“ with the plugin script as parameter.
      I will have a look, if there is any place in the plugin, that could lead to a wrong / missing link.

    55. Comment by D-dig | 20:32 11.09.09|X

      I use wordpress 2.8,
      is blank page

      I try
      Cannot load RandomFlickerFavs2.php.

    56. Comment by Secco | 13:39 13.09.09|X

      Well, it seems that you either have renamed the plugins filename or you put the plugin in a subfolder instead of wp-content/plugins. In both cases RandomFlickrFavs will not generate the correct link for the options page.
      The link in the admin menu should be http://mypage/wp-admin/options-general.php?page=RandomFlickrFavs2.php and the plugin file should have the name „RandomFlickrFavs2.php“.

    Leave a Reply »»

    Note: All comments are manually approved to avoid spam. So if your comment doesn't appear immediately, that's ok. Have patience, it can take some days until I have the time to approve my comments.