Creates an image grid (which keeps aspect ratios) automatically with javascript