I’m following along with the tutorial but I’ve hit a snag. When I try to crop the project images using
<?= $project->image()->crop(500) ?>
I get an error message saying:
This page is currently offline due to an unexpected error. We are very sorry for the inconvenience and will fix it as soon as possible.
Everything displays fine before I add ->crop(500)
I’m on OSX and running a local server using MAMP. PHP ver 7.3.1
Any ideas?
I think you should check first like that
<?php if($image = $page->image()): ?>
<img src="<?= $image->crop(500)->url() ?>" alt="">
<?php endif ?>
Thanks byybora, unfortunately your code didn’t work for me.
I’ve tried uploading my test site to a live server and my code works fine there, cropping the images as intended. So I’m thinking it must a problem with the way MAMP is running? Or the version of PHP on my local server?
Any ideas?
Do you get an error message or is the file just not cropped? Which thumbs driver have you set in your config?
If you are using a wrong PHP version, you would get an error message, because Kirby checks for the PHP version on installation.
I just get this error
I haven’t set any thumbs driver in config, how do I do that?
Ok, an error, then please enable debugging in your config.php
as a first step.
'debug' => true
within the return array, so that it tells us what the error is.
The full code should look like this if the file is currently empty:
return [
'debug' => true
];
If there is no config.php file yet, create one in /site/config/config.php
(the Starterkit comes with a config file, the Plainkit doesn’t).
Thanks texnixe! I think I’ve done it. Did I need to put the code in php tags like this?
return [
'debug' => true
];
Php code has to start with a php tag, yes
<?php
return [
'debug' => true
];
(the php tag didn’t copy in my post for some reason)
Well I think it’s working, I get a debug window now when I refresh my page!
Ok, what does it say now?
lots of stuff! Not sure what’s what. Trying to attach a screen grab…
Looks like PHP Version 7.3.1
I did try to install Valet last night via homebrew etc and something didn’t work with the installation so I wonder if it’s conflicting with MAMP somehow? Is that a possibility?
Which version of Mamp are you using? Changing the PHP version is usually just a click (at least with MAMP Pro).
Also, you can try the solution proposed in the thread I mentioned, after all it seemed to do the trick.
You have to stop the MAMP server before you can use Valet (but both can be installed, I got them both on my system and that works well, I can switch between them if I make sure to stop the one before running the other).
Aha! I changed the PHP version in MAMP to 7.2.14 and it’s working now! Thanks so much @texnixe Amazing support here, def purchasing a license when I get this all up and running, I’m enjoying myself
1 Like