Merge branch 'feature/fix-img-param-abbr'

This commit is contained in:
Cotes Chung 2021-12-13 02:39:44 +08:00
commit 3a4316b29b

View file

@ -71,22 +71,24 @@
{% assign _width = nil %} {% assign _width = nil %}
{% assign _height = 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 %} {% for _attr in _attrs %}
{% capture _key %}{{ _attr | split: '=' | first }}{% endcapture %} {% capture _key %}{{ _attr | split: '=' | first }}{% endcapture %}
{% capture _value %}{{ _attr | split: '=' | last | replace: '"', '' }}{% endcapture %} {% capture _value %}{{ _attr | split: '=' | last | replace: '"', '' }}{% endcapture %}
{% case _key %} {% case _key %}
{% when 'width', 'w' %} {% when 'width' %}
{% assign _width = _value %} {% assign _width = _value %}
{% when 'height', 'h' %} {% when 'height' %}
{% assign _height = _value %} {% assign _height = _value %}
{% endcase %} {% endcase %}
{% if _width and _height %} {% 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 %} {% 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: '<img src="' | append: _svg | append: '" ' | append: _img %} {% assign _img_content = _img_content | append: '<img src="' | append: _svg | append: '" ' | append: _img_converted %}
{% break %} {% break %}
{% endif %} {% endif %}