$(document).ready(function() {
  $("ul#gallery li img").each(function() { // This will set the function for every list item with an img in the grid
    var width = $(this).width(); // 100 + "em"; // this will divide the image witdh by 100 and covert to em's
    var height = $(this).height(); // 100 + "em"; // this will divide the image height by 100 and covert to em's
	var imageurl = $(this).attr("src");
	$(this).attr("style","background-image: url(" + imageurl + ")");
	$(this).attr("src","empty.gif"); 
    $(this).css("width",80); // now we change the hight and width in CSS
    $(this).css("height",80);
  });
});

