Cant get Thumbnails working

Hi, i’m trying to get thumbnails working but i cant figure it out here’s what i have now.

<?php $thumbnail = $project->thumbnailimage(); ?>
background-image: url("<?php echo thumb($thumbnail, array('width' => 600))->url(); ?>");

Thumbnailimage is a “image” type in the .yml file.
$project is the default project tutorial where $projects is $project, $projects = $page->children()->visible()

The error i receive is “unknown” in the css url().

Your $thumbnail is not an image object. To get an image object:

<?php
if($image = $project->thumbnailimage()->toFile()) {
  $url = thumb($image, array('width' => 600))->url();
} else {
  $url = '';
?>
background-image: url("<?= $url ?>")
1 Like

Works perfectly! thanks