Refactor #3938: Fixed a bug of addImage.