Organising images for the gallery