Hi all -
I’m trying to loop through images in my strurture form field and get the following error:
**
Block error: “Call to a member function url() on string” in block type: “videoGrid”
**
The issue seems to be relating to my srcset array of sizes, but this is taken straight from Kirby’s lazy loading guide, so I can’t see where I’m going wrong.
<?php foreach ($item->image()->toFiles() as $image): ?>
<img
loading="lazy" alt="<?= $image->alt() ?>"
src="<?= $image->thumb(['width' => 1280])->url() ?>"
srcset="<?= $image->srcset([320, 640, 960, 1280, 1600, 1920])->url() ?>"
height="<?= $image->height() ?>"
width="<?= $image->width() ?>"
>
<?php endforeach ?>
Block blueprint below:
name: Video grid
fields:
videos:
label: Videos
type: structure
fields:
description:
label: Description
type: text
link:
label: Youtube link
type: url
image:
label: Image
type: files
min: 1
max: 1