fixed a bug with image scaling in gallery