Sha256: 634f2bc1b8da8bda623dcabaf7dd3b14a403e16cd4ac012ecaa3d161c0f679ba

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

{%- comment -%}
  Generate image final URL based on `site.img_cdn`, `page.img_path`

  Arguments:
    src - required, basic image path
    img_path - optional, relative path of image
    absolute - optional, boolean, if true, generate absolute URL

  Return:
    image URL
{%- endcomment -%}

{% assign url = include.src %}

{%- if url -%}
  {% unless url contains ':' %}
    {%- comment -%} Add page image path prefix {%- endcomment -%}
    {% assign url = include.img_path | default: '' | append: '/' | append: url %}

    {%- comment -%} Prepend CND URL {%- endcomment -%}
    {% if site.img_cdn %}
      {% 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 -%}

{{- url -}}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jekyll-theme-chirpy-6.5.5 _includes/img-url.html