refactor gallery thumbnail conditional