Sha256: 98a300969cf4b2b6405825c410f682f0b5e6149e89beb20a43caa34a8930af80

Contents?: true

Size: 1008 Bytes

Versions: 3

Compression:

Stored size: 1008 Bytes

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 -%} CND URL {%- endcomment -%}
    {% assign prefix = site.img_cdn | default: '' %}

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

    {% assign url = prefix
      | append: '/'
      | append: url
      | replace: '///', '/'
      | replace: '//', '/'
      | replace: ':', ':/'
    %}

    {% if include.absolute %}
      {% assign url = site.url | append: site.baseurl | append: url %}
    {% else %}
      {% assign url = site.baseurl | append: url %}
    {% endif %}
  {% endunless %}
{%- endif -%}

{{- url -}}

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
doc-theme-0.1.0 _includes/img-url.html
jekyll-theme-chirpy-6.5.3 _includes/img-url.html
jekyll-theme-chirpy-6.5.2 _includes/img-url.html