VID-1945 removing duplicate code and fixing bug with image links