<% @LANGUAGE="VBSCRIPT" CODEPAGE="65001" %> <% on error resume next 'Amazon AWS Images API ISBN13 = "" ISBN10 ="" imgSize = "MediumImage" imgURL="" if request("p1") <>"" then ISBN13 = trim(request("p1")) end if if request("p2")<>"" then ISBN10 = trim(request("p2")) end if if request("size")<>"" then if request("size")="s" then imgSize="SmallImage" elseif request("size")="m" then imgSize="MediumImage" elseif request("size")="l" then imgSize = "LargeImage" end if end if Response.Buffer = false if Len(ISBN13) = 13 or Len(ISBN10) = 10 then 'check local file system or xml list first Dim fso set fso = createobject("scripting.filesystemobject") 'set root folder Dim pdfFolder Set pdfFolder = fso.GetFolder(Server.MapPath("/img/thm/")) locPDF = "http://" & request.ServerVariables("SERVER_NAME") & "/img/thm" for each file in pdfFolder.Files if left(file.name,13) = ISBN13 then 'cover image if right(file.name,8) = "_thm.jpg" then cvrIMG = pdfFolder & "\" & file.name cvrPath = replace(replace(cvrIMG, pdfFolder, locPDF), "\", "/") end if end if next set fso=nothing set pdfFolder=nothing if cvrPath<>"" then imgURL = cvrPath end if 'if no local image if imgURL = "" then 'then request from Scene 7 if ISBN13 <> "" then imgURL = "https://s7d9.scene7.com/is/image/LifeWayChristianResources/" & ISBN13 & "?hei=160&defaultImage=http://www.bhpublishinggroup.com/images/spacer.gif" end if end if 'img url blank ' ** load image ** loadImage(imgURL) else 'p1 or p2 is the wrong length noImage() end if 'end check p1 p2 input length function loadImage(imgURL) if InStr(imgURL,"/img/thm/")>0 then 'load from local file system segments = split(imgURL,"/") imgFileName = segments(ubound(segments)) Const adTypeBinary = 1 Dim oStream, bData Set oStream = CreateObject("ADODB.Stream") oStream.Type = adTypeBinary oStream.Open oStream.LoadFromFile Server.MapPath("/img/thm/" & imgFileName) bData = oStream.Read Response.ContentType = "image/jpeg" response.BinaryWrite(bData) set oStream = nothing else 'get remote image set xmlhttp = server.CreateObject("MSXML2.ServerXMLHTTP") Response.ContentType = "image/jpeg" xmlhttp.open "GET", imgURL, false xmlhttp.send "" response.BinaryWrite(xmlhttp.responseBody) end if Set xmlhttp = Nothing response.end() end function function noImage() ' if no image specified or found set xmlhttp = server.CreateObject("MSXML2.ServerXMLHTTP") 'return blank image targeturl="http://www.bhpublishinggroup.com/images/spacer.gif" 'return blank image Response.ContentType = "image/gif" 'response.write("not found") xmlhttp.open "GET", targeturl, false xmlhttp.send "" response.BinaryWrite(xmlhttp.responseBody) Set xmlhttp = Nothing response.end() end function 'Google Books API 'http://books.google.com/books?jscmd=viewapi&bibkeys=ISBN9781586402518&callback=ProcessGBSBookInfo 'http://books.google.com/books?vid=ISBN9781586402518&printsec=frontcover %>