Well, I edited my config.php and added the srcsets
hoping that thumbs
means images:
<?php
return [
'routes' => [
[
'pattern' => 'sitemap.xml',
'action' => function() {
$pages = site()->pages()->index();
$ignore = kirby()->option('sitemap.ignore', ['error', 'resume', 'works', 'shows', 'contact', 'privacy', 'legal-notes']);
$resume = page('resume')->children()->pluck('id', ',');
$ignore = array_merge($ignore, $resume);
$shows = page('shows')->children()->pluck('id', ',');
$ignore = array_merge($ignore, $shows);
$content = snippet('sitemap', compact('pages', 'ignore'), true);
return new Kirby\Cms\Response($content, 'application/xml');
}
],
[
'pattern' => 'sitemap',
'action' => function() {
return go('sitemap.xml', 302);
}
],
[
'pattern' => '/',
'action' => function() {
return page('shows')->children()->listed()->shuffle()->first();
}
]
],
'debug' => true,
'languages' => true,
'thumbs' => [
'srcsets' => [
'default' => [
'800w' => ['width' => 800, 'quality' => 80],
'1024w' => ['width' => 1024, 'quality' => 80],
'1440w' => ['width' => 1440, 'quality' => 80],
'2048w' => ['width' => 2048, 'quality' => 80]
]
]
]
];
In my template, I replaced
<?= $painting->image()->resize(1920, 1920)->url() ?>
with
<?= $painting->image()->url() srcset="<?= $painting->srcset([300, 800, 1024]) ?>" ?>
Please see:
<!-- Paintings -->
<section>
<h5><?= page('works')->blueprint()->section('paintings')->headline() ?></h5>
<figure class="gallery">
<?php foreach (page('works')->children()->filterBy('template', 'painting') as $painting): ?>
<figure id="<?= preg_replace('/.*\//', '', $painting->url()) ?>" class="<?= $painting->size() ?>">
<a href="<?= $painting->url() ?>" target="_self"><img src="<?= $painting->image()->url() srcset="<?= $painting->srcset([300, 800, 1024]) ?>" ?>"
alt="<?= $painting->title() ?>"></a>
</figure>
<?php endforeach ?>
</figure>
</section>
<?php endif ?>
Now, I get an error:
ParseError thrown with message “syntax error, unexpected identifier “srcset”, expecting “,” or “;””
What is wrong?