# Modifying image KirbyText tag to display caption from file metadata

**URL:** <https://forum.getkirby.com/t/modifying-image-kirbytext-tag-to-display-caption-from-file-metadata/15768>\
**Category:** Questions\
**Tags:** v3\
**Created:** [September 25, 2019, 3:36pm UTC](https://forum.getkirby.com/t/modifying-image-kirbytext-tag-to-display-caption-from-file-metadata/15768 "2019-09-25T15:36:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![keith](https://avatars.discourse-cdn.com/v4/letter/k/f05b48/32.png) [@keith](https://forum.getkirby.com/u/keith)\
**Post date:** [September 25, 2019, 3:36pm UTC](https://forum.getkirby.com/t/modifying-image-kirbytext-tag-to-display-caption-from-file-metadata/15768/1 "2019-09-25T15:36:05Z")

</div>

In a new Kirby 3 site I am applying image metadata (captions, photographer, etc.) using file blueprints. I insert these images using the `(image: ... )` kirbytext tag. I know you can manually add a caption with the `caption:` attribute when calling the tag. Would I would like to have is the kirbytext tag pull the caption from the image metadata if it exists while also maintaining the option of overwriting that caption if the `caption:` attribute is specified in the `(image: ... )` kirbytext tag. It seems like I should just extend the image kirbytag ([Reusing KirbyTags | Kirby CMS](https://getkirby.com/docs/cookbook/extensions/extending-kirbytags)) but I am having a difficult time getting started. It seems like this would be a common problem, and I did find some solutions for Kirby 2, but none for Kirby 3. Hopefully this will help others as well.

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [September 25, 2019, 4:17pm UTC](https://forum.getkirby.com/t/modifying-image-kirbytext-tag-to-display-caption-from-file-metadata/15768/2 "2019-09-25T16:17:38Z")

</div>

It shouldn’t be necessary to create a custom tag. If you have a field called `caption`, it should be pulled automatically, while the metadata is overwritten if the caption property is used in the tag.

This is the line where this happens:

```auto
$tag->caption = $tag->caption ?? $tag->file->caption()->value();

```

Doesn’t that work? Does for me.

---

<div class="post-metadata">

**Author:** ![keith](https://avatars.discourse-cdn.com/v4/letter/k/f05b48/32.png) [@keith](https://forum.getkirby.com/u/keith)\
**Post date:** [October 17, 2019, 5:36am UTC](https://forum.getkirby.com/t/modifying-image-kirbytext-tag-to-display-caption-from-file-metadata/15768/3 "2019-10-17T05:36:05Z")

</div>

@texnixe, thank you so much for the prompt reply. Yes! You are absolutely right, the default image tag pulls in the `caption`, as well as the `alt`, metadata stored file blueprint. This seems to be new in K3? I seem to recall making my own custom image tag to achieve the same thing in K2. Apologies for the delayed response.
