Switched to callback-style for optimizing image resources