{% assign preview_max_width = page.preview.max_width %} {% assign preview_aspect_ratio = page.preview.aspect_ratio %} {% assign preview_img = page.preview.image %} {% assign preview_src = preview_img.path | default: preview_img | append: '' %} {%- comment -%} `image` may be a mapping ({ path: …, … }) or a bare string (image: /x.png). A mapping without a `path` (e.g. only default style keys, or a video-only preview) stringifies to a Ruby hash dump containing "=>", which would leak into the tag as broken markup — so treat that (and an empty value) as "no image". {%- endcomment -%} {% if preview_src != '' and preview_src != empty %}{% unless preview_src contains '=>' %} {% capture img_style %} {% assign img_aspect_ratio = preview_img.aspect_ratio | default: preview_aspect_ratio %} {% if img_aspect_ratio %}--preview-aspect-ratio: {{ img_aspect_ratio }};{% endif %} {% if preview_img.object_fit %}--preview-object-fit: {{ preview_img.object_fit }};{% endif %} {%- comment -%} Anchor point used when `object_fit: cover` crops the image. `object-position` is written horizontal-then-vertical. {%- endcomment -%} {% if preview_img.object_position_x or preview_img.object_position_y %}--preview-object-position: {{ preview_img.object_position_x | default: 'center' }} {{ preview_img.object_position_y | default: 'center' }};{% endif %} {% assign img_max_width = preview_img.max_width | default: preview_max_width %} {% if img_max_width %}--preview-max-width: {{ img_max_width }};{% endif %} {% endcapture %} {% assign img_style_stripped = img_style | strip %} {% capture style %}{% if img_style_stripped != '' %}style="{{ img_style_stripped }}"{% endif %}{% endcapture %} {% capture src %}src="{{ preview_src }}"{% endcapture %} {% capture class %}class="preview-img{% if preview_img.no_bg %}{{ ' no-bg' }}{% endif %}"{% endcapture %} {% capture alt %}alt="{{ page.preview.alt | default: "Preview Image" }}"{% endcapture %} {% capture lqip %} {% if preview_img.lqip %} lqip="{{ preview_img.lqip }}" {% endif %} {% endcapture %}
{%- if page.preview.alt -%}
{{ page.preview.alt }}
{%- endif -%}
{% endunless %}{% endif %} {%- comment -%} `youtube.url` accepts a YouTube link or a direct video URL — internal (e.g. /assets/video/clip.mp4) or external. `youtube.poster` sets the poster frame for direct