3
votes

I'm using Google Custom Search API for searching images to display in my website. But the thumbnail images are too small and I could not find a way to control the thumbnail size. Here is a response for my query:

{
"kind": "customsearch#result",
"title": "Big Ben Street London United Kingdom Photo Shared By Halsy16 ...",
"htmlTitle": "Big Ben Street \u003cb\u003eLondon United Kingdom\u003c/b\u003e Photo Shared By Halsy16 \u003cb\u003e...\u003c/b\u003e",
"link": "http://www.fansshare.com/photos/london/big-ben-street-london-united-kingdom-784722294.jpg",
"displayLink": "www.fansshare_com",
"snippet": "Robert Pattinson's new London",
"htmlSnippet": "Robert Pattinson's new \u003cb\u003eLondon\u003c/b\u003e",
"mime": "image/jpeg",
"image": {
 "contextLink": "http://www.fansshare_com/gallery/photos/10677077/big-ben-street-london-united-kingdom/",
 "height": 640,
 "width": 1024,
 "byteSize": 80611,
 "thumbnailLink": "https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcSZJRKQ-yIiSt1FCeYdBKLUEft54xHJo095_r9-rN8OrILnOZPnJZvcwNsG",
 "thumbnailHeight": 94,
 "thumbnailWidth": 150
 }    

Can someone please tell me if there's a way to get a bigger thumbnail? Or are there any alternative ways to display the search results like in Google Image Search? Thank you very much!

1
how are you even getting thumbnails? I only get the image link. I am using the .net library rest4net googleconstomsearch - CodeToad

1 Answers

0
votes

I'm assuming you're using the Google Custom Search API since the Image API is deprecated.

There is no way to tell Google to serve a bigger thumbnail size AFAICS, but you have two possible workarounds:

  • use the image url as a CSS background-image property to an element of your chosing (for example, a div with class "portrait"), and use background-position:cover to make sure the image is scaled up or down to cover the whole element screen estate (Here is an example : Andy Warhol 's portrait is fetched via Google)
  • link to the full image instead of the thumbnail (the linkquery parameter you have in your example) (but that can be hazardous since you'll have to avoid huge and too small images)

Make sure to experiment with the api Explorer and its parameters.