# Multiple cover images of a subpage

**URL:** <https://forum.getkirby.com/t/multiple-cover-images-of-a-subpage/22366>\
**Category:** Questions\
**Tags:** v3\
**Created:** [May 19, 2021, 11:59am UTC](https://forum.getkirby.com/t/multiple-cover-images-of-a-subpage/22366 "2021-05-19T11:59:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![exeldoc](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/exeldoc/32/6224_2.png) [@exeldoc](https://forum.getkirby.com/u/exeldoc)\
**Post date:** [May 19, 2021, 11:59am UTC](https://forum.getkirby.com/t/multiple-cover-images-of-a-subpage/22366/1 "2021-05-19T11:59:35Z")

</div>

Hello.

I would like to build a “cover image slider”. So I need to pick not just one but multiple images as cover. Is there any concept to achieve that with php or a cool kirby functions?

I tried this to implement some ideas from this: [Filter to exclude files that contain specific string in their name](https://forum.getkirby.com/t/filter-to-exclude-files-that-contain-specific-string-in-their-name/573)

And i came up with this not working code:

```
<div class="cover_show">
<?php foreach ($cat as $item): ?>
<a class="image_container" href="<?= $item->url() ?>">
          <?=
        $files = $item->files()->filterBy('filename', '*=', 'cover')
          ?>
          <?php foreach ($files as $cover): ?>
            <?= $cover->cover()?>
          <?php endforeach; ?>
        </a>
<?php endforeach; ?>
</div>

```

cover function like this :

```
public function cover()
{
    return $this->content()->get('cover')->toFile() ?? $this->image();
}

```

It looks like the whole `foreach` part is doing nothing – the output is only the string of the images with cover in its filename.

Does anyone have an idea?

---

<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:** [May 19, 2021, 12:09pm UTC](https://forum.getkirby.com/t/multiple-cover-images-of-a-subpage/22366/2 "2021-05-19T12:09:36Z")

</div>

> [@exeldoc](#):
>
> ```auto
> <?php foreach ($files as $cover): ?>
> <?= $cover->cover()?>
> <?php endforeach; ?>
> 
> ```

If $files returns an image collections, then `$cover` is already a file object, so no need to call `cover()`:

```auto
<?php foreach ($files as $cover): ?>
  <?= $cover ?>
<?php endforeach; ?>

```

---

<div class="post-metadata">

**Author:** ![exeldoc](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/exeldoc/32/6224_2.png) [@exeldoc](https://forum.getkirby.com/u/exeldoc)\
**Post date:** [May 19, 2021, 12:26pm UTC](https://forum.getkirby.com/t/multiple-cover-images-of-a-subpage/22366/3 "2021-05-19T12:26:32Z")

</div>

Thanks, it is working.
