Where is the img tag?

Right, so I’m feeling royally and utterly stupid, but I can’t find where the img tag inside the figure tag comes from, when the content comes from content files (as opposed to being hardcoded into templates), as I would like to modify how it gets written out.

I am using a script for responsive images (http://responsiveimg.com/), which is working wonderfully for all my images that are coded into the templates, or that I can predict will be within the content. However, when I hand it all over to the user/client I would like to have a solution in place that is as idiot proof as possible, and I am pretty sure they will do things I can’t predict today, and therefore I would like to be change the img tag and how it gets written out (and not the surrounding figure tag, which I can reach easily).

I have looked, I have searched in all files, and I just can’t find it, probably due to me being stupid, but at the moment my best stab at an explanation to how it ends up in the code is via divine intervention, though I’m guessing that is not correct.

Help would be appreciated. I’ll wear the silly hat afterwards. Thanks.

:smiley:

If you want to modify the way the kirbytext image tag is built, the best way to do that is via a custom kirby tag: http://getkirby.com/docs/advanced/kirbytext. You can just copy the image tag and then modify the parts you want to change.

Other than that, kirbytags (and the way figure tags are built) are defined in kirby/extensions/tags.php, but then it wouldn’t be a good idea to change the core.

Ah, excellent, I was actually just now reading about custom tags, and was hoping that I could write a custom tag that overrides a built-in tag. It looks like the perfect solution indeed, thanks. As you say I would like to not change core as I keep it nicely update-able via Git at the moment. :smile:

Did you get something to work? Im having the same issue.

What exactly is your issue?

The tags are defined in /kirby/extensions/tags.php. If you want to build your own custom tag, copy the image tag from that file and save it into /site/tags, then make your changes as desired. You can either overwrite the original tag by giving your new tag the same name, or give it another name.

Yeah I tried that, but I can’t seem to wrap my head around it. Im basically trying to add a datascr and an extra class to all my kirbytext images.

Hello! :slight_smile:

I want to use a custom Kirbytag to add automatically a class to all image tags within Kirbytext. The problem is, I want to preserve the standard abilities of the image tag and I haven’t enough php or programming knowledge to do it.

Which would be a proper way to do so?

THX in advance!!

Seems like you can extend the built in kirbytags like that:

1 Like

Does this code need a <?php in the beginning?

Have a look at the docs for custom Kirbytags: https://getkirby.com/docs/developer-guide/kirbytext/tags

This would go into site/tags/image.php and indeed need a <?php in the beginning.

1 Like