I am using the panel to edit content and add images in the panel for each article.
However, with the common practice of using images in the background of DIVs by using background-image combined with background-sizing of cover, I stopped rendering images straight into templates, but rather inserted them into the background of the link block or div.
Unfortunately, this removes the automagic of using figures and captions in the markup, as well as using all of the auto-generated image sizing features as well (as I understand it).
In your projects, what is the strategy or tricks you use to get captions that are added in the panel, into your page?
I don’t think using background images makes sense of you want to add captions to an image and make it accessible with useful alt text. There are ways to lazyload and srcset background images via JavaScript.
If you are using background image just for cover and don’t have to support IE11, take a look at object-fit: cover for images. It’s basically the same + all the benefits of classic html image tags.
Applying object-fit and I’m very happy with it. Also, I’ve realized that if people use images within their kirbytext that all works well, it is only with the template version that requires me to add in all the figcaption insertion code. Thanks again, @Thomasorus and @texnixe!
So I’ve altered my method of inserting images into templates to the following (this just grabs the first alphabetical image in the article Files field using the Blueprint preset of Pages):
When converting templates into Kirby, is there anything we should be doing with the srcset attribute, or is that all handled already? I was under the impression K3 handles that but I want to be sure.