Adjust logic for showing category image

This fixes the issues where the category image isn't shown if there
isn't a description. It also extends the logic to use the appropriate
'span%d' class, depending on whether the image and description are
present.