I have a custom block where a user can upload multiple images.
On the front-end I can implement responsive images without a problem. Is it also possible to get this in the panel preview? For the moment I am only able to display the original file. Since this can be very large it is detrimental for performance.
I’ve found following thread:Image sizes in block preview. But I don’t know how to implement the proposed solution.
Any help appreciated.
Maybe the Gallery Block can help? See kirby/Gallery.vue at main · getkirby/kirby · GitHub
When the files field (I assume this is what’s in your blueprint right?) is loaded into the content object it seems to be populated with everything you may need – filename, text and info, (as in the blueprint’s field settings), ration, src, srcset and so on. This is what I did in a similar usage – grabbed the srcset and used that in the block template – just as the Gallery block does.
Or instead – include the Fields Block Plugin as well and in your block preview it will replicate the usual files field layout.