Crop image doesnt work


I’m working on a website based on the kirby theme “One”.
It’s using crop() to crop images on the home and projects template, but it’s not working at all.

there is the source code :

<?php if($project->cover()->isNotEmpty()): $thumb = $project->cover()->toFile()->crop(600, 400);?>
  <img class="img-responsive" src="<?= $thumb->url() ?>" alt="" />
<?php endif ?> spaces 

But it’s not working att all. My images are not cropped.

I looked at the media folder and it’s appear there is no image files corresponding.

Capture d’écran de 2020-06-26 13-47-48

Maybe I’ve to manage my thumb in the config file, but it’s seems weird that the default config of Kirby doesn’t work.

Thank’s a lot

The first thing would be to check if the image object exists before you call the crop method:

<?php if ($file =  $project->cover()->toFile()) :
  $thumb = $file->crop(600, 400); ?>
  <img class="img-responsive" src="<?= $thumb->url() ?>" alt="" />
<?php endif ?>

Testing if cover is empty is not necessary then.

However, there seems to be another problem, because the jobs are created but not the thumbs themselves…

Yes it’s weird, when I add a new project in the back office and save jobs are created but ther is no image in the media folder.

Image are created when I recharge the page, not thumbs, only the image source…

Are you using the standard gd library or imagemagick in config? If you haven’t set a config option, then gd is the default, so make sure gd is present and enabled (check phpinfo()).

What web server are you using? Is this locally or on a remote server?

Okay, I understand where is my problem.

I’ve some troubles with my php and Server installation.
I’ve reinstall all the missing library and it’s working well now !