Crowley Code! 
 (Take 12)

wp-screenshots plugin 2008/01/22

Ever wanted Wordpress to display small screenshots of pages you're linking to like the del.icio.us homepage?  Neither have I but a friend wanted it and I wanted to build a Wordpress plugin, so here it is.

wp-screenshots takes the URL of a del.icio.us RSS feed as input and gives back a <ul> containing thumbnails from the unofficial Snap API.

Installation is as easy as running svn co http://svn.rcrowley.org/svn/wp-screenshots/ ./ in your wp-content/plugins/ directory.  You can then use the PHP function screenshots() anywhere in your templates.  As a bonus, if you setup wp-screenshots.php to run as a cronjob, it'll understand what's up and just hit the proper image URLs to make sure Snap's cache is primed for your page views.

http://svn.rcrowley.org/svn/wp-screenshots/

Comments (6)

  1. would have been nice if you used the plugin in this post. :-)

    Paul Stamatiou — 2008/01/23 1:01 am

  2. Interesting.  I've been looking for some documentation on the snap API, and this is about as much as I've found, so many thanks!

    However, I can't seem to get the request URL to work for me..  I always get back the capturing gif, and never get the actual shot:

    http://direct.shots.snap.com/preview/?v=3.11&size=small&lang=en-us&url=http%3A%2F%2Fjounce.net

    Are there other options to the size parameter, such as large or medium?  Since I seem to be making some sort of mistake, I can't just go and see for myself.

    Thanks for the great info!

    M. Jackson Wilkinson — 2008/01/23 1:53 pm

  3. @ M. Jackson Wilkinson, if you type those in, you'll see large is the other option, giving 427x274 jpegs. http://www.snap.com/snapshots_faq.php#Parameters has a list that's semi-related of the parameters.

    If you want larger pictures, webkit2png is wonderful on macs, there are random solutions for linux, but I haven't heard of any that I would describe as great.  You can create a job that runs the script to create the image on your server once and you're set, rather than relying on Snaps (which I hate for many reasons, not least of which is that I can't make them update the image of my site, I try, but it doesn't work).

    David Hall — 2008/01/23 2:32 pm

  4. @ M. Jackson Wilkinson: The link you posted in the comment actually displays correctly now.  They don't have a screenshot for everything but once something is requested the first time, they generate and cache the thumbnail.  The cronjob mode of the plugin is there to address this issue.

    Richard Crowley — 2008/01/23 2:43 pm

  5. Gotcha -- I suppose I was being a bit too impatient :) Thanks for the info, and thanks for the head start with the plugin!

    M. Jackson Wilkinson — 2008/01/24 6:47 am

  6. Thank you :) Ms. Baratz will benefit from this.

    You forgot to mention that free food inspired this plugin.

    Andrew Mager — 2008/01/25 12:41 pm

Richard Crowley?  Kentuckian engineer who cooks and eats in between bicycling and beering.

I blog mostly about programming and databases.  Browse by month or tag.

To blame for...


© 2009 Richard Crowley.  Managed by Bashpress.