added erros handling in base templates when adding images