DRY up handling of image_description
for alternative text
This commit is contained in:
parent
cb8cb6f41e
commit
f7a1b1a160
2 changed files with 18 additions and 6 deletions
|
@ -22,6 +22,14 @@
|
||||||
{% capture overlay_filter %}rgba(0, 0, 0, {{ page.header.overlay_filter }}){% endcapture %}
|
{% capture overlay_filter %}rgba(0, 0, 0, {{ page.header.overlay_filter }}){% endcapture %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% if page.header.image_description %}
|
||||||
|
{% assign image_description = page.header.image_description %}
|
||||||
|
{% else %}
|
||||||
|
{% assign image_description = page.title %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% assign image_description = image_description | markdownify | strip_html | strip_newlines | escape_once %}
|
||||||
|
|
||||||
<div class="page__hero{% if page.header.overlay_color or page.header.overlay_image %}--overlay{% endif %}"
|
<div class="page__hero{% if page.header.overlay_color or page.header.overlay_image %}--overlay{% endif %}"
|
||||||
style="{% if page.header.overlay_color %}background-color: {{ page.header.overlay_color | default: 'transparent' }};{% endif %} {% if overlay_img_path %}background-image: {% if overlay_filter %}linear-gradient({{ overlay_filter }}, {{ overlay_filter }}), {% endif %}url('{{ overlay_img_path }}');{% endif %}"
|
style="{% if page.header.overlay_color %}background-color: {{ page.header.overlay_color | default: 'transparent' }};{% endif %} {% if overlay_img_path %}background-image: {% if overlay_filter %}linear-gradient({{ overlay_filter }}, {{ overlay_filter }}), {% endif %}url('{{ overlay_img_path }}');{% endif %}"
|
||||||
>
|
>
|
||||||
|
@ -45,11 +53,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
{% if page.header.image_description %}
|
<img src="{{ img_path }}" alt="{{ image_description }}" class="page__hero-image">
|
||||||
<img src="{{ img_path }}" alt="{{ page.header.image_description }}" class="page__hero-image">
|
|
||||||
{% else %}
|
|
||||||
<img src="{{ img_path }}" alt="{{ page.title }}" class="page__hero-image">
|
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if page.header.caption %}
|
{% if page.header.caption %}
|
||||||
<span class="page__hero-caption">{{ page.header.caption | markdownify | remove: "<p>" | remove: "</p>" }}</span>
|
<span class="page__hero-caption">{{ page.header.caption | markdownify | remove: "<p>" | remove: "</p>" }}</span>
|
||||||
|
|
|
@ -22,6 +22,14 @@
|
||||||
{% capture overlay_filter %}rgba(0, 0, 0, {{ page.header.overlay_filter }}){% endcapture %}
|
{% capture overlay_filter %}rgba(0, 0, 0, {{ page.header.overlay_filter }}){% endcapture %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% if page.header.image_description %}
|
||||||
|
{% assign image_description = page.header.image_description %}
|
||||||
|
{% else %}
|
||||||
|
{% assign image_description = page.title %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% assign image_description = image_description | markdownify | strip_html | strip_newlines | escape_once %}
|
||||||
|
|
||||||
<div class="page__hero{% if page.header.overlay_color or page.header.overlay_image %}--overlay{% endif %}"
|
<div class="page__hero{% if page.header.overlay_color or page.header.overlay_image %}--overlay{% endif %}"
|
||||||
style="{% if page.header.overlay_color %}background-color: {{ page.header.overlay_color | default: 'transparent' }};{% endif %} {% if overlay_img_path %}background-image: {% if overlay_filter %}linear-gradient({{ overlay_filter }}, {{ overlay_filter }}), {% endif %}url('{{ overlay_img_path }}');{% endif %}"
|
style="{% if page.header.overlay_color %}background-color: {{ page.header.overlay_color | default: 'transparent' }};{% endif %} {% if overlay_img_path %}background-image: {% if overlay_filter %}linear-gradient({{ overlay_filter }}, {{ overlay_filter }}), {% endif %}url('{{ overlay_img_path }}');{% endif %}"
|
||||||
>
|
>
|
||||||
|
@ -45,7 +53,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<img src="{{ img_path }}" alt="{{ page.title }}" class="page__hero-image">
|
<img src="{{ img_path }}" alt="{{ image_description }}" class="page__hero-image">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if page.header.caption %}
|
{% if page.header.caption %}
|
||||||
<span class="page__hero-caption">{{ page.header.caption | markdownify | remove: "<p>" | remove: "</p>" }}</span>
|
<span class="page__hero-caption">{{ page.header.caption | markdownify | remove: "<p>" | remove: "</p>" }}</span>
|
||||||
|
|
Loading…
Reference in a new issue