For some reason this snippet prints double images of every image coming from the media-page.
Not sure how this happend. Beside that I’m also spotting new duplicate files being created in the content folder. Does this has something to do with the crop I’m making?
for example:
thy3-1536x1536.jpeg
—> original
thy3-1536x1536-min.jpeg
—> duplicate (or is it a minified version?)
I hope you’ll spot the bug
the snippet:
<?php if ($site->page('media')->images()->isNotEmpty()): ?>
<?php foreach ($site->page('media')->images() as $image): ?>
<div class="swiper-slide">
<a href="<?= $image->url() ?>" class="glightbox" data-gallery="gallery">
<figure>
<picture>
<source srcset="<?= $image->srcset([
'400w' => ['width' => 400, 'height' => 400, 'crop' => 'center', 'format' => 'avif'],
'800w' => ['width' => 800, 'height' => 800, 'crop' => 'center', 'format' => 'avif'],
'1200w' => ['width' => 1200, 'height' => 1200, 'crop' => 'center', 'format' => 'avif']
]) ?>" type="image/avif">
<source srcset="<?= $image->srcset([
'400w' => ['width' => 400, 'height' => 400, 'crop' => 'center', 'format' => 'webp'],
'800w' => ['width' => 800, 'height' => 800, 'crop' => 'center', 'format' => 'webp'],
'1200w' => ['width' => 1200, 'height' => 1200, 'crop' => 'center', 'format' => 'webp']
]) ?>" type="image/webp">
<img src="data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 width=%271200%27 height=%271800%27 style=%27background:%23a9bacf%27 /%3E"
srcset="<?= $image->srcset([
'400w' => ['width' => 400, 'height' => 400, 'crop' => 'center', 'format' => 'jpeg'],
'800w' => ['width' => 800, 'height' => 800, 'crop' => 'center', 'format' => 'jpeg'],
'1200w' => ['width' => 1200, 'height' => 1200, 'crop' => 'center', 'format' => 'jpeg']
]) ?>" alt="A highly optimized image">
</picture>
<figcaption><?= $image->caption() ?></figcaption>
</figure>
</a>
</div>
<?php endforeach ?>
<?php endif ?>