Extending Kirbytext Image, best practice?

version 5.0.4

What is the process/best practice to extend an existing Kirbytag?

I’m looking to add support for data-* attributes to the image Kirbytag. I use data- attributes to add private hooks for CSS and JS in my html, and it the only missing piece for me to go from inline HTML in my content to using the image Kirbytag.

Thanks

Thanks aware of this page, but my understanding is this is replacing the kirbytag, not extending it. Am I missing something or is the recommended best practice to rewrite the kirbytag in a plugin?

It needs to be overridden. You can’t extend it and just merger extra attributes in to it im afraid.

If it helps, here is the default image tag. kirby/config/tags.php at 5.1.2 · getkirby/kirby · GitHub

You can just copy that iinto your own plugin and add the stuff you need to that attrs / html areas. It will take prescdence over the built in one when you `(image: file.jpg….)` as long as it hs the same name as the default tag.

1 Like

bummer, thanks for the quick responses!

1 Like