Use link title as fallback for caption

This works because the title doesn't exist if there's no caption and we
won't get to this logic branch if the thumbnail is an explicit |thumb|
with a caption already.

Refactored caption-fetching a bit.

Change-Id: If84c890e7b71880db640a0993f8e3d6cd59951b8
Mingle: https://wikimedia.mingle.thoughtworks.com/projects/multimedia/cards/513
Merge "Use link title as fallback for caption"