Fix bug in firefox with image replacement