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 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vgmzx8VTTTmCskSpQtsLTr
This commit is contained in:
@@ -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 @@
|
||||
|
||||
<div class="story-hero" id="story-hero">
|
||||
<div class="story-hero__img-wrap">
|
||||
{% if hero %}
|
||||
<img src="{{ hero.url }}" alt="{{ page.header.hero_alt ?? page.title }}" class="story-hero__img" loading="eager">
|
||||
{% if hero_url %}
|
||||
<img src="{{ hero_url }}" alt="{{ page.header.hero_alt ?? page.title }}" class="story-hero__img" loading="eager">
|
||||
{% else %}
|
||||
<div class="story-hero__img-placeholder"></div>
|
||||
{% endif %}
|
||||
|
||||
Reference in New Issue
Block a user