Check and replace image code