如何过滤Wordpress图库标题?

I would like to filter my wordpress galleries caption text. When an image caption is empty, I would like to add the post title + $i. The output code should be:

<dl>
  <dt>
    <a><img src="http://example.com"></a>
  </dt>
  <dd>
    POST TITLE 1
  </dd>
</dl>

I have been looking for a wp_get_attachment_metadata filter but I couldn't find a solution.

Thank you.