Lolcats Widget |

Lolcats Widget

Here is a funny plugin. All it does is actually give you the opportunity of adding a small widget on the sidebar to display the latest LolCat from ICanHasCheezburger. If you don’t already know what a lolcat is then please visit their about page. Also, the Wikipedia article is very enlightening. Now to the point.


This simple plugin retreives the latest lolcat and displays it on a widget. It caches it for two hours so it won’t slow up the process of loading each time.




You need to make sure of two things:

  1. You have GD library with jpeg support installed.
  2. The folder within lolcats_widget (the plugin’s folder) called “cheezes” is writable by the webserver.


Download the plugin from here: Lolcats Widget (2330) - 9.2 KB. In there you will find the folder lolcats_widget. Just copy the whole folder in your plugins directory. Go to your administration and activate the plugin. Finaly, place the widget where you want it on the sidebar.


Because i don’t know wether this plugin will be even remotely usefull to anyone i didn’t bother creating any settings page or settings on the widget setup. If i see it is indeed usefull i’ll go on and do it (why don’t you drop a comment on the post “voting” for further development). For now, you can tweak it from within the code (no, do not worry, i’ll show you where and what). Just open the file “lolcats_widget/lolcats_widget.php” with your favorite text editor (i recommend notepad++) and go ahead…

Changing some settings

When you open it, please notice this area (from line 14 to 19):

  2. $cache_timeout = 7200;//two hours caching before bringing in the new one
  3. $image_path = ABSPATH.PLUGINDIR.‘/lolcats_widget/cheezes/latest.jpeg’;//path to save image
  4. $link_path = ABSPATH.PLUGINDIR.‘/lolcats_widget/cheezes/link.txt’;//path to save image
  5. $final_image_width = 150;//200px default width for image
  6. $use_blank = true;//add an _blank to the lolcats page or not
  7. //—–END DEFINITIONS—————

Now, as you can see some of the “behavioral” settings are defined here. Change them as you need. For instance if you want the cache to timeout earlier than two hours change the “$cache_timeout” to how many seconds you want. Or, if you want the cache directory to be something else rather than the “cheezes” one change it on the next two lines (for instance “/tmp”). The “final_image_width” is actually the width that the lolcat will have after it is resized. Finaly, “use_blank” is a boolean that indicates whether the lolcats page should open on a new window (_blank) or not. Change it according to your theme.

Tweaking the output

Well if you are a bit more adventurus you can fix the output of the widget anyway you want it. It’s a fairly small plugin but i’ll still guide you guys through this just for those that are not as comfortable. Notice lines 63-72.

  1. function widget_cheezburger($args) {
  2.     $link = cheezburger_widget_image_retreiver();
  3.     extract($args);
  4.     echo $before_widget;
  5.     echo $before_title;?>LolCat‘s Latest!<?php echo $after_title;?>
  6.     <?php echo $link;?>
  7.     <img alt="lolcats" src="<?php bloginfo(‘url‘);?>/wp-content/plugins/lolcats_widget/cheezes/latest.jpeg"><br>
  8.     <?php
  9.     echo $after_widget;
  10. }

This actually is the function that renders the small widget. So let’s say you want to add something after the image. You can write any HTML after line 69. If you want to add it before then shoot between 68 and 69. Pretty easy. And if you still feel uncomfortable just let me know with a simple comment and i’ll get to work to add a small options page.


  • 1.0 -> 1.0.1
    • Added the “use_blank” feature.

18 Responses to “ “Lolcats Widget”

  1. […] The download page is here. […]

  2. […] a very nice talk with a user of the “Lolcats Widget” plugin two things happened. One, a small update and two i added comments to my pages on the […]

  3. MacBros says:

    Still waiting for the updated version…. 🙄 LOL

  4. stratosg says:

    @MacBros: i had updated the wordpress ditectory since last night but i forgot to do it with my local copy 🙁 anyway it’s done now… for any more problems feel free!

  5. Martin says:

    Activation of the plugin breaks my theme – even without selecting the widget! Will wait a while to see if you can improve it.

  6. stratosg says:

    @Martin: do you have an example? can you post a screenshot? also are you sure it’s my plugin cause it does nothing till the widget is located on the sidebar… sounds pretty weird…

  7. […] Lolcats Widget – This plugin will retrieve the latest lolcat and display as a widget. If you don’t know what lolcats is/are, you can visit the site and review the about page. While lolcats are an interesting diversion, I see no reason to display the latest on your blog. I also think that lolcats have become as overused as “I can haz”, “FAIL”, “FTW”, and “Internets”. If you haven’t seen any of those terms before, follow a ton of people on Twitter, do nothing but stare at the tweets all day, and then pray these trends end soon. […]

  8. […] i read this article about my lolcats widget plugin. Before i say what i have to say, i would first want to note that i really appreciate any comment […]

  9. Brian says:

    Great plugin, just what I needed! It is working great except I just noticed that when the latest lolcat is a video like this one:

    It breaks the theme and throws errors all over it. Any way to not have it update if it is a video or to show the video instead of a pic? Thanks!

  10. stratosg says:

    @Brian: to be honest i did not predict that when i wrote it. i will see if i can come up with a fix..

Leave a Reply