fix(post): correct the image URLs (#1627)

This commit is contained in:
Cotes Chung 2024-03-24 02:28:28 +08:00 committed by GitHub
parent b7aa05d03a
commit 2d649aae0e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 12 additions and 16 deletions

View File

@ -17,24 +17,20 @@
{%- comment -%} Add page image path prefix {%- endcomment -%} {%- comment -%} Add page image path prefix {%- endcomment -%}
{% assign url = include.img_path | default: '' | append: '/' | append: url %} {% assign url = include.img_path | default: '' | append: '/' | append: url %}
{%- comment -%} CND URL {%- endcomment -%} {%- comment -%} Prepend CND URL {%- endcomment -%}
{% if site.img_cdn %} {% if site.img_cdn %}
{% assign url = site.img_cdn {% assign url = site.img_cdn | append: '/' | append: url %}
| append: '/' {% endif %}
| append: url
| replace: '///', '/'
| replace: '//', '/'
| replace: ':/', '://'
%}
{% unless site.img_cdn contains ':' %} {% assign url = url | replace: '///', '/' | replace: '//', '/' | replace: ':/', '://' %}
{% unless url contains '://' %}
{% if include.absolute %} {% if include.absolute %}
{% assign url = site.url | append: site.baseurl | append: url %} {% assign url = site.url | append: site.baseurl | append: url %}
{% else %} {% else %}
{% assign url = site.baseurl | append: url %} {% assign url = site.baseurl | append: url %}
{% endif %} {% endif %}
{% endunless %} {% endunless %}
{% endif %}
{% endunless %} {% endunless %}
{%- endif -%} {%- endif -%}