Added automatic detection of height for preview image