Page model doesn't work for image object

Hey all,

I’m having bit of a struggle with page models. I have home.php in the models directory with the code:


class HomePage extends Page {
  public function thumbnail() {
    // crop image and return
    return $this->crop(640, 480);

In the template home.php I have:

<?php echo $slider_image->thumbnail()->url(); ?>

With slider image using the selector field. All works fine until I use the thumbnail function. If i put:

<?php echo $slider_image->crop(640, 480)->url(); ?>

It works without issues.

Appreciate any help I can get.

A page model extends the functionality of Page objects, not of File objects. You can read more about how they work in the docs.

Kirby 2.3 will have file methods, so you can put this into a plugin file in the Kirby 2.3 beta:

file::$methods['thumbnail'] = function($file) {
  return $file->crop(640, 480);

Ahhh makes sense, thanks!