Trying to get kirbytext() to use srcset in 3.1.0

I’ve managed to get srcset working for my image fields as per the documentation. Noice! :slight_smile:

I’m now trying to get srcset working for images in kirbytext().

Any ideas where to start looking in order to achieve this?

The image Kirbytag doesn’t use srcset by default. You could, however, either override the default image Kirbytag or create a custom tag with srcset support.

Overriding a tag means to create a tag with the same tag name.

It might be worth checking out @bnomei’s srcset plugin as it has support for srcset kirbytag (amongst other things).

There’s also a brand new cookbook quicktip that shows how to reuse parts of existing tags in custom tags (2nd example with simple srcset)


I like the new cookbook recipe. Would have saved me some time to write another custom imagetag with srcset and lazyloading a few days ago.

Thanks! This looks great. I managed to cobble something together before I saw this but will look to adopt this I think :slight_smile:

I added the plugin from the quicktip

Now using imageset in the textarea field still just outputs an image with src only.


What did you add in your textarea field?

(imageset: my-image.jpg)

That’s what I suspected. If you don’t use the newly added srcset attribute with a comma separated list of srcset values, there will be no change whatsoever.

(imageset: my-image.jpg srcset: 300, 600, 900, 1200)

For more options, you might want to use one of the existing plugins.

1 Like