Image block and srcset


how can I use srcset() on Blocks when rendering the Blocks with toBlocks()?

Or is there any way to tell Kirby to add srcset to all images by default?


You can override the snippets for the image/gallery blocks and add srcset support

Thank you!

hi, sorry for opening this up again, but i did not understand how i can add srcset into my block-loop. where sholud i override what?
thank you very much!
(enjoying but still learning kirby)

i’m looping through my blocks like this:

<?php foreach ($page->Blocks()->toBlocks() as $block): ?>
  <div id="<?= $block->id() ?>" class="block block-type-<?= $block->type() ?>">
      <?= $block ?>
<?php endforeach ?>

Hi and welcome to the forum.

You don’t do that in the loop, but in a custom block snippets, see Overview | Kirby CMS

cool, thanks alot!