From 790cf303769ffc2465bd0026609e4872c0162068 Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Tue, 7 Dec 2021 00:50:01 +0800 Subject: [PATCH] Add abbreviation support for image width/height --- _includes/refactor-content.html | 4 ++-- _layouts/post.html | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/_includes/refactor-content.html b/_includes/refactor-content.html index 7e899ff8f..b5b77b46e 100644 --- a/_includes/refactor-content.html +++ b/_includes/refactor-content.html @@ -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 %} diff --git a/_layouts/post.html b/_layouts/post.html index 222f20a43..ef2450e0c 100644 --- a/_layouts/post.html +++ b/_layouts/post.html @@ -16,8 +16,18 @@ tail_includes: {% endcapture %} {{ page.image.alt | default: + + {% 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 %}

{{ page.title }}