Tuesday, July 29th, 2008

Ajax-Alexa-Thumbnails: API to get site thumbnails

Category: Library, Yahoo!

<>p>Have you ever wanted to be able to easily grab a thumbnail image that represents a website?

Eric Ferraiuolo has created Ajax-Alexa-Thumbnails on Google Code, a library that builds on YUI to do just that.

The project consists of a server-side component written in PHP which makes the cross-domain request to Amazon’s Alexa Site Thumbnail web service, and a JavaScript component which makes Ajax requests to configured server-side component and caches the results.

How do you call it?

javascript
< view plain text >
  1. (function(){
  2.     YAHOO.util.Event.onDOMReady(function(){    
  3.         var container = YAHOO.util.Dom.get("container");
  4.        
  5.         YAHOO.EDF.Thumbnail.init({
  6.             source: "alexa_service.php",
  7.             size:   "large",
  8.             anchor: true
  9.         });
  10.        
  11.         YAHOO.EDF.Thumbnail.getThumbnail("http://code.google.com/p/ajax-alexa-thumbnails/", function(thumbnail){
  12.             container.appendChild(thumbnail);
  13.         }).getThumbnail("http://developer.yahoo.com/yui/", function(thumbnail){
  14.             container.appendChild(thumbnail);
  15.         });    
  16.     });
  17. }());

Since this uses Alexa, it can’t give you a snapshot of any page out there.

Related Content:

Posted by Dion Almaer at 7:11 am
7 Comments

+++--
3.7 rating from 33 votes

7 Comments »

Comments feed TrackBack URI

I really miss the good old days when tasks as simple as that could be coded as:

[img src="/cgi-bin/thumbnail.cgi?url=http%3A//ajaxian.com/&size=64x64"]

Comment by Jordan — July 29, 2008

Anyone else think that’s a ridiculous amount of code?

Comment by ajaxery — July 29, 2008

I dont even see the point of the thumbnails so that looks like rediculouse code anyways.. And it indeeds looks like it could be a shitload shorter…

Comment by V1 — July 29, 2008

Sorry for such a verbose example, but you could code it down to something more like this:

var Thumbnail = YAHOO.EDF.Thumbnail;
Thumbnail.init({ source:”alexa_service.php” });
Thumbnail.getThumbnail(“http://www.google.com”, function(thumb){ //alert(thumb); });

Comment by eferraiuolo — July 29, 2008

>>Since this uses Alexa, it can’t give you a snapshot of any page out there.
.
Really? None?
.
How about, “Since this uses Alexa, it can’t give you a snapshot of every page out there.”
.
or, “Note that not all pages have Alexa snapshots.”

Comment by Nosredna — July 29, 2008

Nosredna:
On come on, ‘just’ before ‘any’ is obviously implied. Syntactic semantic pedantry generally does not improve language coherency as far as the reader, or even the writer, is concerned while parsing the language in question; such behavior provides little to no benefit, it merely adds unnecessary complexity by polluting language with unnecessary detail which could be discerned from context simply by recognizing the context, parsing it and applying what’s observed from context to the particular bit being parsed by the reader at that particular moment in time. ;)

Comment by eyelidlessness — July 30, 2008

Please note that this is not a free service, even if the code is GPL. It costs $0.0002 / thumbnail returned / no charge if the thumbnail does not exist. http://www.amazon.com/gp/browse.html?node=236156011

Comment by dt — July 31, 2008

Leave a comment

You must be logged in to post a comment.