2024-01-10 04:04:27 +03:00
|
|
|
{%- comment -%}
|
|
|
|
Generate image final URL based on `site.img_cdn`, `page.img_path`
|
|
|
|
|
|
|
|
Arguments:
|
|
|
|
src - basic image path, required
|
|
|
|
img_path - relative path of image, optional
|
|
|
|
|
|
|
|
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 -%}
|
|
|
|
{% assign prefix = site.img_cdn | default: '' | relative_url %}
|
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: ':', ':/'
|
|
|
|
%}
|
|
|
|
{% endunless %}
|
2024-01-10 04:04:27 +03:00
|
|
|
{%- endif -%}
|
|
|
|
|
|
|
|
{{- url -}}
|