This repository has been archived on 2025-03-28. You can view files and clone it, but cannot push or open issues or pull requests.
coryd.dev-eleventy/src/_includes/partials/media/grid.liquid

64 lines
No EOL
2.8 KiB
Text

{% assign hidePagination = count or data.pages.size <= 1 %}
{% assign media = data.items | default: data | normalizeMedia %}
<div class="media-grid {% if shape == 'square' %}square{% else %}vertical{% endif %}">
{% for item in media limit: count | default: media.size %}
{% assign alt = item.alt | strip | escape %}
<a href="{{ item.url | stripUtm }}" title="{{ alt }}">
<div class="item-wrapper shadow">
<div class="meta-text">
{% if item.title %}
<div class="header">{{ item.title }}</div>
{% endif %}
{% if item.plays %}
<div class="subheader">{{ item.plays }} plays</div>
{% elsif item.subtext %}
<div class="subheader">{{ item.subtext }}</div>
{% endif %}
</div>
{% assign loadingStrategy = loading | default: 'lazy' %}
{% if shape == 'square' %}
<img
srcset="
https://coryd.dev/.netlify/images/?url={{ item.image }}&fit=cover&w=200&h=200&fm=webp&q=40 200w,
https://coryd.dev/.netlify/images/?url={{ item.image }}&fit=cover&w=400&h=400&fm=webp&q=40 400w,
https://coryd.dev/.netlify/images/?url={{ item.image }}&fit=cover&w=800&h=800&fm=webp&q=40 800w,
https://coryd.dev/.netlify/images/?url={{ item.image }}&fit=cover&w=1200&h=1200&fm=webp&q=40 1200w
"
sizes="(max-width: 450px) 200px,
(max-width: 850px) 400px,
(max-width: 100px) 800px,
1200px"
src="https://coryd.dev/.netlify/images/?url={{ item.image }}&fit=cover&w=1200&h=1200&fm=webp&q=40"
alt="{{ alt }}"
loading="{{ loadingStrategy }}"
decoding="async"
width="240"
height="240"
/>
{% else %}
<img
srcset="
https://coryd.dev/.netlify/images/?url={{ item.image }}&fit=cover&w=200&h=307&fm=webp&q=40 200w,
https://coryd.dev/.netlify/images/?url={{ item.image }}&fit=cover&w=400&h=614&fm=webp&q=40 400w,
https://coryd.dev/.netlify/images/?url={{ item.image }}&fit=cover&w=800&h=1228&fm=webp&q=40 800w,
https://coryd.dev/.netlify/images/?url={{ item.image }}&fit=cover&w=1200&h=1842&fm=webp&q=40 1200w
"
sizes="(max-width: 450px) 200px,
(max-width: 850px) 400px,
(max-width: 1000px) 800px,
1200px"
src="https://coryd.dev/.netlify/images/?url={{ item.image }}&fit=cover&w=1200&h=1842&fm=webp&q=40"
alt="{{ alt }}"
loading="{{ loadingStrategy }}"
decoding="async"
width="200"
height="307"
/>
{% endif %}
</div>
</a>
{% endfor %}
</div>
{% unless hidePagination %}
{% render "partials/widgets/paginator.liquid", pagination:data %}
{% endunless %}