Kirbytext image class from file

I know that you can add a class when inserting an image in kirbytext like (image: whatever.jpg class: my-awesome-class).

However, I would like to be able to add the class by including a class field in the descriptive text file

The reason: when users are adding images in the control panel, I would like to include a class field that lets them choose from a dropdown of available classes (if that’s even an option in the blueprints for files, I haven’t checked).

Is such a thing possible?

Yes, both is possible.

Ad 1: You would have to make a copy of the image tag and save it in a plugin file. Modify as required.
Ad 2: You can use any type of available fields for your meta data, like with pages.

Oh look, I already have a custom image tag. I’ll see if I can work that in.

Done. Excellent.

I set it up so that if there’s a class attribute, it overrides anything that might be in the descriptive file, which means that if people are doing this by editing the normal text file and they understand and are happy with the Kirby methods, then they can continue doing that. If they’re using the control panel and would rather use the dropdown method when editing the file, they can do that.