rewrote imagegrid directive