How can I put captions to the grid of images?

I’m using a smart solution for achieve a grid of images (a group of images in colums).

Here the Solution of @nleanba: Grid - how display picture on 2 columns programmatically - #8 by nleanba

But How can I put captions to the grid of images?

Can you give a minimal working example of your grid (replacing the images with #rect(...) or similar)?