VID-1945 some refactoring of image thumbnails code