1
0
mirror of https://github.com/cotes2020/jekyll-theme-chirpy.git synced 2025-06-21 11:10:53 +00:00

fix: improve accuracy of moving img element classes (#2399)

This commit is contained in:
Cotes Chung 2025-05-11 22:19:18 +08:00 committed by GitHub
parent 401e2af0f8
commit d0f8f9553e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -88,9 +88,41 @@
{% endfor %} {% endfor %}
<!-- take out classes --> <!-- take out classes -->
{% assign _wrapper_class = '' %}
{% if _class %} {% if _class %}
{% capture _old_class %}class="{{ _class }}"{% endcapture %} {% assign _remain = _class %}
{% assign _left = _left | remove: _old_class %} {% assign _class_array = _class | split: ' ' %}
{% for c in _class_array %}
{% assign _pick = false %}
{% case c %}
{% when 'preview-img', 'normal', 'left', 'right', 'light', 'dark' %}
{% assign _pick = true %}
{% else %}
{% if c contains '-' %}
{% assign start = c | split: '-' | first %}
{% if start == 'w' %}
{% assign _pick = true %}
{% endif %}
{% endif %}
{% endcase %}
{% if _pick %}
{% assign _remain = _remain | remove: c | strip %}
{% assign _wrapper_class = _wrapper_class | append: ' ' | append: c %}
{% endif %}
{% endfor %}
{% unless _wrapper_class == '' %}
{% capture _old_class %}class="{{ _class }}"{% endcapture %}
{% assign _left = _left | remove: _old_class %}
{% unless _remain == '' %}
{% capture _new_class %}class="{{ _remain }}"{% endcapture %}
{% assign _left = _left | append: _new_class %}
{% endunless %}
{% endunless %}
{% endif %} {% endif %}
{% assign _final_src = null %} {% assign _final_src = null %}
@ -110,7 +142,7 @@
{% if _lqip %} {% if _lqip %}
{% assign _lazyload = false %} {% assign _lazyload = false %}
{% assign _class = _class | append: ' blur' %} {% assign _wrapper_class = _wrapper_class | append: ' blur' %}
{% unless _lqip contains 'data:' %} {% unless _lqip contains 'data:' %}
{% assign _lqip_alt = 'lqip="' | append: _path_prefix %} {% assign _lqip_alt = 'lqip="' | append: _path_prefix %}
@ -121,7 +153,7 @@
{% assign _left = _left | replace: 'src=', 'data-src=' | replace: ' lqip=', ' data-lqip="true" src=' %} {% assign _left = _left | replace: 'src=', 'data-src=' | replace: ' lqip=', ' data-lqip="true" src=' %}
{% else %} {% else %}
{% assign _class = _class | append: ' shimmer' %} {% assign _wrapper_class = _wrapper_class | append: ' shimmer' %}
{% endif %} {% endif %}
<!-- lazy-load images --> <!-- lazy-load images -->
@ -153,8 +185,8 @@
{% assign _wrapper_start = _final_src {% assign _wrapper_start = _final_src
| default: _src | default: _src
| prepend: '<a href="' | prepend: '<a href="'
| append: '" class="popup img-link ' | append: '" class="popup img-link'
| append: _class | append: _wrapper_class
| append: '">' | append: '">'
%} %}