2024-01-10 04:04:27 +03:00
|
|
|
{%- comment -%}
|
|
|
|
Generate image final URL based on `site.img_cdn`, `page.img_path`
|
|
|
|
|
|
|
|
Arguments:
|
2024-01-28 00:53:54 +03:00
|
|
|
src - required, basic image path
|
|
|
|
img_path - optional, relative path of image
|
|
|
|
absolute - optional, boolean, if true, generate absolute URL
|
2024-01-10 04:04:27 +03:00
|
|
|
|
|
|
|
Return:
|
|
|
|
image URL
|
|
|
|
{%- endcomment -%}
|
|
|
|
|
|
|
|
{% assign url = include.src %}
|
|
|
|
|
|
|
|
{%- if url -%}
|
2024-01-10 21:11:25 +03:00
|
|
|
{% unless url contains ':' %}
|
|
|
|
{%- comment -%} CND URL {%- endcomment -%}
|
2024-01-28 00:53:54 +03:00
|
|
|
{% assign prefix = site.img_cdn | default: '' %}
|
2024-01-10 04:04:27 +03:00
|
|
|
|
2024-01-10 21:11:25 +03:00
|
|
|
{%- comment -%} Add page image path prefix {%- endcomment -%}
|
|
|
|
{% assign url = include.img_path | default: '' | append: '/' | append: url %}
|
2024-01-10 04:04:27 +03:00
|
|
|
|
2024-01-10 21:11:25 +03:00
|
|
|
{% assign url = prefix
|
|
|
|
| append: '/'
|
|
|
|
| append: url
|
|
|
|
| replace: '///', '/'
|
|
|
|
| replace: '//', '/'
|
|
|
|
| replace: ':', ':/'
|
|
|
|
%}
|
2024-01-28 00:53:54 +03:00
|
|
|
|
|
|
|
{% if include.absolute %}
|
2024-02-22 22:07:17 +03:00
|
|
|
{% assign url = site.url | append: site.base_url | append: url %}
|
2024-01-28 00:53:54 +03:00
|
|
|
{% else %}
|
2024-02-22 22:07:17 +03:00
|
|
|
{% assign url = site.base_url | append: url %}
|
2024-01-28 00:53:54 +03:00
|
|
|
{% endif %}
|
2024-01-10 21:11:25 +03:00
|
|
|
{% endunless %}
|
2024-01-10 04:04:27 +03:00
|
|
|
{%- endif -%}
|
|
|
|
|
|
|
|
{{- url -}}
|