From f4b2dfe8b4699e7b761741526dcbb59c0b730df2 Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Sun, 12 Dec 2021 00:38:49 +0800 Subject: [PATCH] Fix the conversion of image width/height abbreviation --- _includes/refactor-content.html | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/_includes/refactor-content.html b/_includes/refactor-content.html index d58c41a..d958cda 100644 --- a/_includes/refactor-content.html +++ b/_includes/refactor-content.html @@ -71,22 +71,24 @@ {% assign _width = nil %} {% assign _height = nil %} - {% assign _attrs = _img | split: '>' | first | split: ' ' %} + + {% assign _img_converted = _img | replace: ' w=', ' width=' | replace: ' h=', ' height=' %} + {% assign _attrs = _img_converted | split: '>' | first | split: ' ' %} {% for _attr in _attrs %} {% capture _key %}{{ _attr | split: '=' | first }}{% endcapture %} {% capture _value %}{{ _attr | split: '=' | last | replace: '"', '' }}{% endcapture %} {% case _key %} - {% when 'width', 'w' %} + {% when 'width' %} {% assign _width = _value %} - {% when 'height', 'h' %} + {% when 'height' %} {% assign _height = _value %} {% endcase %} {% if _width and _height %} {% capture _svg %}data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 {{_width}} {{_height}}'%3E%3C/svg%3E{% endcapture %} - {% assign _img_content = _img_content | append: '