Add abbreviation support for image width/height

This commit is contained in:
Cotes Chung 2021-12-07 00:50:01 +08:00
parent cf8dae9454
commit 790cf30376
2 changed files with 14 additions and 4 deletions

View file

@ -78,9 +78,9 @@
{% capture _value %}{{ _attr | split: '=' | last | replace: '"', '' }}{% endcapture %}
{% case _key %}
{% when 'width' %}
{% when 'width', 'w' %}
{% assign _width = _value %}
{% when 'height' %}
{% when 'height', 'h' %}
{% assign _height = _value %}
{% endcase %}

View file

@ -16,8 +16,18 @@ tail_includes:
{% endcapture %}
<img src="{{ page.image.src }}" class="preview-img {{ bg | strip }}"
alt="{{ page.image.alt | default: "Preview Image" }}"
{% if page.image.width %}width="{{ page.image.width }}"{% endif %}
{% if page.image.height %}height="{{ page.image.height }}"{% endif %}>
{% if page.image.width %}
width="{{ page.image.width }}"
{% elsif page.image.w %}
width="{{ page.image.w }}"
{% endif %}
{% if page.image.height %}
height="{{ page.image.height }}"
{% elsif page.image.h %}
height="{{ page.image.h }}"
{% endif %}>
{% endif %}
<h1 data-toc-skip>{{ page.title }}</h1>