From 2d649aae0e40a24db1ab0d46fa474294e96cb135 Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Sun, 24 Mar 2024 02:28:28 +0800 Subject: [PATCH] fix(post): correct the image URLs (#1627) --- _includes/img-url.html | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/_includes/img-url.html b/_includes/img-url.html index 20620b7..bb4758c 100644 --- a/_includes/img-url.html +++ b/_includes/img-url.html @@ -17,24 +17,20 @@ {%- comment -%} Add page image path prefix {%- endcomment -%} {% assign url = include.img_path | default: '' | append: '/' | append: url %} - {%- comment -%} CND URL {%- endcomment -%} + {%- comment -%} Prepend CND URL {%- endcomment -%} {% if site.img_cdn %} - {% assign url = site.img_cdn - | append: '/' - | append: url - | replace: '///', '/' - | replace: '//', '/' - | replace: ':/', '://' - %} - - {% unless site.img_cdn contains ':' %} - {% if include.absolute %} - {% assign url = site.url | append: site.baseurl | append: url %} - {% else %} - {% assign url = site.baseurl | append: url %} - {% endif %} - {% endunless %} + {% assign url = site.img_cdn | append: '/' | append: url %} {% endif %} + + {% assign url = url | replace: '///', '/' | replace: '//', '/' | replace: ':/', '://' %} + + {% unless url contains '://' %} + {% if include.absolute %} + {% assign url = site.url | append: site.baseurl | append: url %} + {% else %} + {% assign url = site.baseurl | append: url %} + {% endif %} + {% endunless %} {% endunless %} {%- endif -%}