Show grid gallery captions only if caption is set

Removes the empty grey rectangle on images in a grid gallery when no
caption is set, so that the grid gallery behaves like all other gallery
types.