Skip to content

Commit 2d649aa

Browse files
authored
fix(post): correct the image URLs (#1627)
1 parent b7aa05d commit 2d649aa

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

_includes/img-url.html

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,20 @@
1717
{%- comment -%} Add page image path prefix {%- endcomment -%}
1818
{% assign url = include.img_path | default: '' | append: '/' | append: url %}
1919

20-
{%- comment -%} CND URL {%- endcomment -%}
20+
{%- comment -%} Prepend CND URL {%- endcomment -%}
2121
{% if site.img_cdn %}
22-
{% assign url = site.img_cdn
23-
| append: '/'
24-
| append: url
25-
| replace: '///', '/'
26-
| replace: '//', '/'
27-
| replace: ':/', '://'
28-
%}
29-
30-
{% unless site.img_cdn contains ':' %}
31-
{% if include.absolute %}
32-
{% assign url = site.url | append: site.baseurl | append: url %}
33-
{% else %}
34-
{% assign url = site.baseurl | append: url %}
35-
{% endif %}
36-
{% endunless %}
22+
{% assign url = site.img_cdn | append: '/' | append: url %}
3723
{% endif %}
24+
25+
{% assign url = url | replace: '///', '/' | replace: '//', '/' | replace: ':/', '://' %}
26+
27+
{% unless url contains '://' %}
28+
{% if include.absolute %}
29+
{% assign url = site.url | append: site.baseurl | append: url %}
30+
{% else %}
31+
{% assign url = site.baseurl | append: url %}
32+
{% endif %}
33+
{% endunless %}
3834
{% endunless %}
3935
{%- endif -%}
4036

0 commit comments

Comments
 (0)