# Query field from structure within block within layout

**URL:** <https://forum.getkirby.com/t/query-field-from-structure-within-block-within-layout/32421>\
**Category:** Questions\
**Tags:** v4\
**Created:** [September 6, 2024, 12:56pm UTC](https://forum.getkirby.com/t/query-field-from-structure-within-block-within-layout/32421 "2024-09-06T12:56:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![momonu](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/momonu/32/15264_2.png) [@momonu](https://forum.getkirby.com/u/momonu)\
**Post date:** [September 6, 2024, 12:56pm UTC](https://forum.getkirby.com/t/query-field-from-structure-within-block-within-layout/32421/1 "2024-09-06T12:56:48Z")

</div>

Hi, i am trying to retrieve the URL of the first few images of a page to preload them. Those images are in a structure in a block in a layout.

So I have a page with layout with blocks and a block called teaser:

```auto
name: Teaser
fields:
  items:
    type: structure
    fields:
      image:

```

Now I would like to get the image urls from the first teaser block on the page.

I tried iterating through the layouts columns and blocks, but it seemed very complicated. Is there a more straightforward way?

Something like:

```auto
$items = $page->layout()->toLayouts()->columns()->blocks()->filterBy('type', 'teaser')->first()->items();
foreach ($items as $item) {
   // $item->image()->link()
}

```

Thanks, Mathis

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [September 6, 2024, 1:30pm UTC](https://forum.getkirby.com/t/query-field-from-structure-within-block-within-layout/32421/2 "2024-09-06T13:30:32Z")

</div>

You can convert all layouts to blocks: [$layouts-\>toBlocks() | Kirby CMS](https://getkirby.com/docs/reference/objects/cms/layouts/to-blocks), then filter

---

<div class="post-metadata">

**Author:** ![momonu](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/momonu/32/15264_2.png) [@momonu](https://forum.getkirby.com/u/momonu)\
**Post date:** [September 6, 2024, 1:35pm UTC](https://forum.getkirby.com/t/query-field-from-structure-within-block-within-layout/32421/3 "2024-09-06T13:35:17Z")

</div>

Thanks! I got it working 🙂

```auto

$items = $page->layout()->toLayouts()->toBlocks()->filterBy('type', 'teaser')->first()->items()->toStructure();
foreach ($items as $item) {
   // use $item->image()->toFile()->url();
}

```
