refactored pop up code, added max image display size