Avoid NoneType exception when previewing images