Refactor preview image

Move some logic to PreviewController.