Prevent duplication of images when replacing existing image.

#6249