nouveau-theatre-de-besancon/site/snippets/picture.php
isUnknown 53a2ed8b0f webp
2024-09-19 14:20:55 +02:00

33 lines
997 B
PHP

<?php if (isset($file)): ?>
<?php
$sizes = isset($size) ? '(min-width: 800px) ' . $size . 'vw, 100vw' : '(min-width: 800px) 50vw, 100vw';
$alt = $alt ?? $file->alt();
$crop = $crop ?? false;
$webPSrcset = $file->srcset('webp');
$srcset = $file->srcset();
$src = $file->url();
$width = $file->resize(1800)->width();
$height = $file->resize(1800)->height();
$class = isset($class) ? 'class="' . $class . '"': '';
$lazy = $lazy ?? true;
?>
<picture <?= $class ?>>
<source srcset="<?= $webPSrcset ?>"
sizes="<?= $sizes ?>" type="image/webp">
<img
src="<?= $src ?>"
srcset="<?= $srcset ?>"
sizes="<?= $sizes ?>"
width="<?= $width ?>"
height="<?= $height ?>"
alt="<?= $alt?>"
<?= e($lazy, 'loading="lazy"') ?>
>
<div class="loader"></div>
</picture>
<?php endif ?>