Refactored image plugin