Hi, my focus doesn`t apply on my website even though i set it. Why does this happen, and what did i do wrong or leave out.
Im quite new to Kirby and its the first time testing this feature out, sorry about that.
Any help would be much appreciated.
Hi, my focus doesn`t apply on my website even though i set it. Why does this happen, and what did i do wrong or leave out.
Im quite new to Kirby and its the first time testing this feature out, sorry about that.
Any help would be much appreciated.
id be happy to share the code snippets if that helps:
gallery-section.php snippet
<?php if($artworks && $artworks->count() > 0): ?>
<?php foreach($artworks as $artwork): ?>
<?php
// Prefer cover field, fallback to first image
$image = $artwork->cover()->toFile() ?? $artwork->image();
// Debug information
echo "<!-- Artwork: " . $artwork->title() . " -->\n";
if ($image) {
echo "<!-- Image focus point: " . $image->focus()->value() . " -->\n";
echo "<!-- Image dimensions: " . $image->width() . "x" . $image->height() . " -->\n";
}
?>
<section class="gallery__section"
data-title="<?= $artwork->title() ?>"
data-artist="<?= $artwork->artist() ?>"
data-location="<?= $artwork->location() ?>"
data-year="<?= $artwork->year() ?>"
data-category="<?= $artwork->category() ?>">
<?php if($image): ?>
<?php
// Get viewport dimensions (default to 1920x1080 if not set)
$width = $kirby->request()->get('width', 1920);
$height = $kirby->request()->get('height', 1080);
// Process image with focus point
$processedImage = $image->crop($width, $height, [
'quality' => 90
]);
?>
<img class="gallery__image"
src="<?= $processedImage->url() ?>"
alt="<?= $artwork->title() ?>"
width="<?= $width ?>"
height="<?= $height ?>"
loading="lazy">
<?php else: ?>
<div class="gallery__image" style="background-color: #eee;"></div>
<?php endif ?>
</section>
<?php endforeach ?>
I’m happy to post more snippets or blueprints if that helps
Hi, welcome to the Kirby forum.
Are the original image dimensions larger than the target dimensions?