I’m currently building a blog template and stumbled over the issue that if I use excerpt() on the overview and the article starts with an image, the image gets strip out. Any idea how to avoid that without adding something like a featured image or do I have the wrong expectation or miss something?
The excerpt function in Kirby core says “Creates an excerpt without html and kirbytext” so yeah, it strips html elements.
The excerpt function from the toolkit has an option for this though, as the third argument to the function, so you could create your own function or plugin (or perhaps override it? I’m not familiar enough yet with Kirby to be sure) and do something like:
Hm,
taking into account that I’m relatively new to kirby and my development skills are a bit rusty I think I’ll go with the Cover/Featured Image after all.
@twirx I now added a Cover Image Field to the Article Blueprint, as a textfield. Is it possible to drag n’ drop images from the files into something else than a textarea, I’m stuck neither type: text nor url gives me that functionality.
Kirby offers a variety of different field types that allow you to fully customize your backend. You might have a look at the documentation which has a very useful overview of all available field types.
I’d use the select field type with dynamically populated select options or the new visual file select field type (Github) by @DieserJonas.
This runs the HTML result of the kirbytext through the excerpt function, returning HTML if set to false. (see docs).
Should be noted that the length count respects characters only and that it’s complicated to control the amount of HTML objects, eg. limit to only one image or element. One is better off with an optional teaser field in these cases.