Calculate height of thumbnails based on definitions.

The previous logic can fail for hidden contents.
Don't shrink thumbnail smaller than 0 width tab