auto resize preview based on content