jQuery Google Image Plugin

Here is a quick and convenient Google Image plugin for jQuery. Just give it an IMG tag with an empty src or a default image. It will use the alt text of your image, and select the first image based on that term.

$.fn.googleImage = function() {
return $(this).each(function() {
var self = this;
var url = "http://ajax.googleapis.com/ajax/services/search/images?v=1.0&rsz=2&start=1&callback=?&q=" + $(this).attr("alt");
$.getJSON(url, function(data) {
if(data.responseData.results.length > 0)
$(self).attr("src", data.responseData.results[0].unescapedUrl);