Closed manuel-fleig closed 2 years ago
Are you sure your image
is actually an image? Doesn't seem that way. The ratio()
method will work on images solely.
Could you provide a minimal reproducible example?
Yep, sure:
<?php $items = $page->projects()->toStructure()->shuffle()?>
<?php foreach ($items as $item): ?>
<div>
<img src="<?= $item->project()->toFile()->placeholderUri() ?>"
data-src="<?= $item->project()->toFile()->url() ?>" data-lazyload
alt="<?= $item->project()->toFile()->alt() ?>" />
</div>
<?php endforeach ?>
it works perfectly on all other pages, but here it crashes.
Could you implement a safeguard?
<?php foreach ($items as $item): ?>
<?php if (!$item->project()->toFile()) continue ?>
Actually, I postulate that it's not the plugin, but an error in the data structure.
Found the mistake, haha. You were right in the first place. There was a PDF between the images i didn't notice.
Thanks for the quick Support @johannschopplich , i really love your plugin :)
Thanks, glad to hear you're enjoying the plugin and also found the bug! 🙂
Hey, I´m getting the following error when using the plugin for images inside a structure field:
it's in this line of site/plugins/kirby-blurry-placeholder/classes/KirbyExtended/BlurryPlaceholder.php:
$height = sqrt($pixelTarget / ($ratio ?? $file->ratio()));
What might be wrong here?