added function for loading images in preview