Refactor image source helpers