Calling a structure field "media" returns error

I renamed a structure field and called it media. And then I got “Call to a member function first() on null”. If I change the name to anything it works. Just when using the name “media” I get the error.

media: fields/media
$media = $page->media()->toStructure()->first();

Even the .txt have the media data after I save the page. Really not sure what’s going on… Is the name media() reserved in Kirby and can’t be used?

Hm, I just tested this in a Starterkit’s about page and it didn’t throw an error.

Do you use any custom methods that might interfere?

You could try

$media = $page->content()->media()->toStructure()->first();

instead

1 Like

Ah indeed I have a method called media :slight_smile: I was going nuts :sweat_smile: :sweat_smile: