Added image replacement function