[Web4lib] Amazon image function

Tim Spalding tim at librarything.com
Wed Jan 30 14:09:10 EST 2008


You can do an onload on the img tag, and then test the size of the resulting
image. So:
1. Try to load Amazon image
2. Image is 1x1
3. Javascript changes src to a default image of your choosing.

We did that for a while on LibraryThing, but we often had so many images
that it was running this stuff hundreds of times. Now we try to remember if
Amazon has an image or not. But we don't store the image. Free bandwidth?
Okay!

T

On 1/30/08, Walker, David <dwalker at calstate.edu> wrote:
>
> Glen, et al.,
>
> It seems to me that the advantage of querying Amazon to see if there is a
> book jacket would be to put in place some type of dummy 'no image available'
> image in the event Amazon doesn't have one.
>
> But if you're not going to do that, you could save yourself a lot of extra
> work and potential problems by simply hard coding the image HTML into the
> page like this:
>
> <img src="http://images.amazon.com/images/P/$isbn.01.THUMBZZZ.jpg" />
>
> If Amazon doesn't have a jacket for that book, it simply returns a blank
> image, which your users won't see.  Ultimately, that's not all that
> different from what you have in your code now, and a lot less work.
>
> --Dave
>
> -------------------
> David Walker
> Library Web Services Manager
> California State University
> http://xerxes.calstate.edu
>
> ________________________________
>
> From: web4lib-bounces at webjunction.org on behalf of Glen Wiley
> Sent: Tue 1/29/2008 1:39 PM
> To: web4lib at webjunction.org
> Subject: [Web4lib] Amazon image function
>
>
>
> Hi everyone,
>
> I know people have discussed Amazon book images issues on this listserv
> before, but here is a more technical question.
>
> I'm using this php code to pull Amazon book cover images into a new book
> list.  It does work, but I wondered if anyone had a suggestion about how
> to do it better.  We aren't getting very many successful image displays
> because many of them time out or error out.  So out of 100 new books, I
> get 10 images appear.  Any suggestions here?
>
> function RESTQuery($isbn){
>    //1VE157GS2Z7SMVS61G02
>    $base         = 'http://ecs.amazonaws.com/onca/xml';
>    $query_string = '';
>
>    $params = array(
>        'ItemId' => "$isbn",
>        'IdType' => "ASIN",
>        'Service' => 'AWSECommerceService',
>        'Operation' => 'ItemLookup',
>        #'SearchIndex' => 'Books',
>        #'sort'  => '+relevance',
>        'ResponseGroup'  => 'Images',
>        'AWSAccessKeyId' => '1VE157GS2Z7SMVS61G02',
>        'Style' =>    "XML",
>        'XMLEscaping' => "Double",
>        'Version'    => "2007-07-16"
>    );
>
>    foreach ($params as $key => $value) {
>        $query_string .= "$key=" . urlencode($value) . "&";
>    }
>
>    $url = "$base?$query_string";
>
>    $xmlstr = file_get_contents($url);
>    if($xmlstr == "") return;
>    $xml = new SimpleXMLElement($xmlstr);
>    #return $xml->asXml();
>    $imageURL = $xml->Items->Item->MediumImage->URL;
>
>    if($imageURL != ""){
>        return "<a href=\"http://www.amazon.com\"><img src=\"$imageURL\"
> /></a>";
>    }
>    else{
>        return "";
>    }
> }
>
>
> --Glen
>
>
>
> ------------------------------------------------------------------------
>
> Glen Wiley
> Metadata Librarian
>
> Metadata Services <http://metadata.library.cornell.edu/>
>
> 107E Olin Library
> Cornell University
> Ithaca, NY 14853/
> /gsw55 at cornell.edu <mailto:gsw55 at cornell.edu>
> 607-254-5145
>
>
> --/ Our Vision is to be internationally recognized and respected as a
> center of metadata expertise. --/
>
>
>
> _______________________________________________
> Web4lib mailing list
> Web4lib at webjunction.org
> http://lists.webjunction.org/web4lib/
>
> _______________________________________________
> Web4lib mailing list
> Web4lib at webjunction.org
> http://lists.webjunction.org/web4lib/
>



-- 
Check out my library at http://www.librarything.com/profile/timspalding


More information about the Web4lib mailing list