Smarter scaling of images for display on Story overview

The existing code only scales based on width, resulting in tall
images being cut off. This patch scales on width or height,
whichever will allow the entire image to be displayed.

So that non-square images are displayed nicely, they are centred
after scaling.