From 229532ab8baa6cebe262a99da277ec0a9ce84f84 Mon Sep 17 00:00:00 2001 From: Mischa Date: Sat, 20 Jun 2026 16:31:26 +0200 Subject: [PATCH] fix(story): fall back to direct URL when page.media fails due to media.types config override user/config/media.yaml defines only 'gpx', which replaces the system media.types instead of merging (blueprint-unaware key replacement). This causes page.media[hero_image] to return undefined for jpg/png files. Fallback constructs the hero URL directly from page.url + filename, matching what shortcode plugins already do. The page.media path is still tried first so it works correctly if the config is ever fixed. Co-Authored-By: Claude Sonnet 4.6 Claude-Session: https://claude.ai/code/session_01Vgmzx8VTTTmCskSpQtsLTr --- themes/intotheeast/templates/story.html.twig | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/themes/intotheeast/templates/story.html.twig b/themes/intotheeast/templates/story.html.twig index 549bf83..f725b45 100644 --- a/themes/intotheeast/templates/story.html.twig +++ b/themes/intotheeast/templates/story.html.twig @@ -6,9 +6,14 @@ {% endblock %} {% block content %} -{% set hero = null %} -{% if page.header.hero_image and page.media[page.header.hero_image] is defined %} - {% set hero = page.media[page.header.hero_image] %} +{% set hero_url = null %} +{% if page.header.hero_image %} + {% if page.media[page.header.hero_image] is defined %} + {% set hero_url = page.media[page.header.hero_image].url %} + {% else %} + {# Fallback: media.types merge may have dropped image types; build URL directly #} + {% set hero_url = page.url ~ '/' ~ page.header.hero_image %} + {% endif %} {% endif %} {% set date_str = page.date|date('d M Y') %} @@ -32,8 +37,8 @@
- {% if hero %} - {{ page.header.hero_alt ?? page.title }} + {% if hero_url %} + {{ page.header.hero_alt ?? page.title }} {% else %}
{% endif %}