Code: + Thumbalizr screenshots + caching

I’m playing with my Delicious Snapcasa code this weekend to see if I can replace Snapcasa with the screenshot-service. Snapcasa was great because it gave me plenty of free captures each month, but it has some serious problems capturing some of the sites I throw at it, and was behaving rather randomly, so it has to go.

I’ve looked at several screen shot services, and tested many, and so far it is that seem to be the fastest and most stable, and the free version is able to take screenshots of webpages deeper into the site, not just the front page. As far as I can see I can’t find any limit on the api, but the free version does have a watermark on each thumb. I’m too cheap to spring for a paid account, but you do have that option.

The result so far

Shows: The last 100 bookmarks tagged with «art» on by me.

Caching provides a .gz with some php for caching the thumbnails their API provides, but I wasn’t able to get it to work last night. Luckily Anton Lindquist has branched the code on GitHub and made some improvements, and after a little headscratching (aka googleing) and some helpful tips from Anton himself, I am now running a version that grabs the images from Thumbalizer and stores them locally on my server, speeding up the pages quite a lot, easing the stress on thumbalizer, and most importantly, preventing already grabbed pages from being queued again and again.

New default queue image

Thumbalizr provides an OK queue-image while their services works on grabbing a screen shot of the page you request but with some help from Anton I’m not using my own custom image, currently a picture of my son holding a fish (just to make him smile :). It’s nice to have a little more control over what is displayed on the page until the image is ready for use, especially when you do like me and fire off a grid of many screen shots on the same page.

Possible uses

I’ve rewritten my original Snapcasa script into a WordPress plugin which I use on several of my blogposts right now. I’ve also made a standalone page for my sons, a start page with kid friendly games and YouTube-videos etc. They can’t read yet, so it’s nice to have an automated start page with pictures.

The code

I promised to update this post with the code I use for working with the Thumbalizr api and caching images locally. As I said I use this caching script instead of the code provided by Thumbalizr. It comes with an example index.php, that I’ve expanded on a little. Right now it looks like this.

	'local_cache_expire' => (!$config['local_cache_expire']) ? 3600 : $config['local_cache_expire'],

$image = new thumbalizrRequest($config);



if($image->headers['Status'] == 'OK' || $image->headers['Status'] == 'LOCAL') {
} else {
	//print_r($image->headers); //debug

$filename = '';
$size = getimagesize($filename);
$fp = fopen($filename, "rb");
if ($size && $fp) {
    header("Content-type: {$size['mime']}");
} else {
    // error



The last 9 bookmarks tagget with «wordpress» and «webdev»

Screenshot for

Infinite Scroll | jQuery plugin, Wordpress plugin, interaction design pattern

Screenshot for

5 Tips For Using jQuery with WordPress / Eric Martin /

Screenshot for

Tutorial: Adding Buttons To The Post Editor — WPCandy — WordPress Themes, Plugins, Tips, and Tricks

Screenshot for

Including jQuery in WordPress (The Right Way) | Digging into WordPress

Screenshot for

WordPress › Stray Random Quotes « WordPress Plugins

Screenshot for

Random WordPress Plugins: Rotating Banners, Header Art, Images, Quotes, and Content on Your Blog « Lorelle on WordPress

Screenshot for

JPF Quotes WordPress Plugin | So Joe...

Screenshot for

Practical Uses for the Post-Thumbnail Function in WordPress 2.9 | Onextrapixel - Showcasing Web Treats Without Hitch

Screenshot for

WordPress Plugin Coding Tips « planetOzh

Screenshot for

Anatomy of a WordPress Plugin | Nettuts+

  1. I know this is an old post, but I just ran across it.
    When I try to use your script, I get a strange problem.. It says that it cannot modify header information.
    Have you come across this error before? Any help would be greatly appreciated. Thanks!

Comments are closed