Replaced the blank loading image with HTML trick.

This commit is contained in:
Cotes Chung 2020-06-01 16:51:32 +08:00
parent ef3860004e
commit 75e462a9e9
2 changed files with 2 additions and 6 deletions

View file

@ -67,13 +67,9 @@ layout: default
{% if page.image %}
<img src="{{ page.image }}">
{% endif %}
<!-- Add lozad class into image tags. see: <https://github.com/ApoorvSaxena/lozad.js#usage> -->
<!-- Using lozad. See: <https://github.com/ApoorvSaxena/lozad.js#usage> -->
{% if content contains '<img src=' %}
{% capture loading %}
{{ "/assets/img/commons/loading.png" | relative_url }}
{% endcapture %}
{% assign replacement = '<img src=' | append: loading | append: ' data-src=' %}
{{ content | replace: '<img src=', replacement }}
{{ content | replace: '<img src=', '<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" data-src=' }}
{% else %}
{{ content }}
{% endif %}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 99 B