# Virtual pages from image gallery with Kirby 4

**URL:** https://forum.getkirby.com/t/virtual-pages-from-image-gallery-with-kirby-4/30194
**Category:** Questions
**Created:** [December 4, 2023, 11:39am UTC](https://forum.getkirby.com/t/virtual-pages-from-image-gallery-with-kirby-4/30194 "2023-12-04T11:39:35Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![pixel](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/pixel/32/12944_2.png) [@pixel](https://forum.getkirby.com/u/pixel)
#### Post date: [December 4, 2023, 11:39am UTC](https://forum.getkirby.com/t/virtual-pages-from-image-gallery-with-kirby-4/30194/1 "2023-12-04T11:39:35Z")

</div>

With Kirby 3 I used [this](https://getkirby.com/docs/cookbook/templating/virtual-pages-image-gallery?cmdf=getkirby+virtual+pages) tutorial to create my image gallery. The update gives me the following error:

```auto
public function image(?string $filename = null)

```

> Whoops \ Exception \ ErrorException (E\_COMPILE\_ERROR)
> 
> Declaration of FotoPage::image(?string $filename = null) must be compatible with Kirby\Cms\Page::image(?string $filename = null): ?Kirby\Cms\File

---

<div class="post-metadata">

### Author: ![jimbobrjames](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/jimbobrjames/32/5802_2.png) [@jimbobrjames](https://forum.getkirby.com/u/jimbobrjames)
#### Post date: [December 4, 2023, 11:52am UTC](https://forum.getkirby.com/t/virtual-pages-from-image-gallery-with-kirby-4/30194/2 "2023-12-04T11:52:06Z")

</div>

Please see here [Virutal pages on Kirby 4 - #2 by jimbobrjames](https://forum.getkirby.com/t/virutal-pages-on-kirby-4/30169/2)

---

<div class="post-metadata">

### Author: ![pixel](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/pixel/32/12944_2.png) [@pixel](https://forum.getkirby.com/u/pixel)
#### Post date: [December 4, 2023, 12:23pm UTC](https://forum.getkirby.com/t/virtual-pages-from-image-gallery-with-kirby-4/30194/3 "2023-12-04T12:23:49Z")

</div>

This does not solve the problem unfortunately.

---

<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: [December 4, 2023, 12:30pm UTC](https://forum.getkirby.com/t/virtual-pages-from-image-gallery-with-kirby-4/30194/4 "2023-12-04T12:30:13Z")

</div>

The signature for the image method has changed, so you need to add the return type `?Kirby\Cms\File`, that’s what @jimbobrjames meant, only with another example…

---

<div class="post-metadata">

### Author: ![pixel](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/pixel/32/12944_2.png) [@pixel](https://forum.getkirby.com/u/pixel)
#### Post date: [December 4, 2023, 12:36pm UTC](https://forum.getkirby.com/t/virtual-pages-from-image-gallery-with-kirby-4/30194/5 "2023-12-04T12:36:59Z")

</div>

Unfortunately I still don’t know what to change since I don’t have the knowledge :-(.

---

<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: [December 4, 2023, 12:40pm UTC](https://forum.getkirby.com/t/virtual-pages-from-image-gallery-with-kirby-4/30194/6 "2023-12-04T12:40:29Z")

</div>

> [@pixel](#):
>
> `public function image(?string $filename = null)`

```auto
public function image(string $filename = null): Kirby\Cms\File|null
{
 // code
}

```

The information after the colon is the return type hint, it tells you what a function will return.

In this case, you will get either a Kirby\Cms\File object, or null.

In Kirby 4, we added a lot more type hints to methods, so some of this might still need a fix in the docs.

---

<div class="post-metadata">

### Author: ![pixel](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/pixel/32/12944_2.png) [@pixel](https://forum.getkirby.com/u/pixel)
#### Post date: [December 4, 2023, 12:53pm UTC](https://forum.getkirby.com/t/virtual-pages-from-image-gallery-with-kirby-4/30194/7 "2023-12-04T12:53:09Z")

</div>

Thank you! Everything else worked fine after the upgrade! Maybe you could edit the tutorial pages too.
