2018-11-12 21:54:33 +01:00
{%- comment -%}
Usage: include icons/placeholder.svg args
2018-11-08 18:33:02 +01:00
2018-11-12 21:54:33 +01:00
args can be one of the following:
title: Used in the SVG `title` tag
text: The text to show in the image - default: 'width x height'
class: default: 'bd-placeholder-img'
2018-11-21 19:59:21 +01:00
color: The text color (foreground) - default: '#dee2e6'
background: The background color - default: '#868e96'
2018-11-12 21:54:33 +01:00
width: default: 100%
height: default: 180px
{%- endcomment -%}
2018-11-08 18:33:02 +01:00
2018-12-13 14:09:47 +01:00
{%- assign title = include.title | default: 'Placeholder' -%}
2018-11-12 21:54:33 +01:00
{%- assign class = include.class | default: '' -%}
2018-11-21 19:59:21 +01:00
{%- assign color = include.color | default: site.data.grays[2].hex -%}
{%- assign background = include.background | default: site.data.grays[5].hex -%}
2018-11-12 21:54:33 +01:00
{%- assign width = include.width | default: '100%' -%}
{%- assign height = include.height | default: '180' -%}
2018-11-08 18:33:02 +01:00
2018-11-12 21:54:33 +01:00
{%- if include.text -%}
{%- assign text = include.text -%}
2018-11-08 18:33:02 +01:00
{%- else -%}
2018-11-12 21:54:33 +01:00
{%- assign text = width | append: 'x' | append: height -%}
2018-11-08 18:33:02 +01:00
{%- endif -%}
2018-11-12 21:54:33 +01:00
{%- capture svg -%}
2018-12-13 14:09:47 +01:00
<svg class= "bd-placeholder-img{% if class != '' %} {{ class }}{% endif %}" width= "{{ width }}" height= "{{ height }}" xmlns= "http://www.w3.org/2000/svg" preserveAspectRatio= "xMidYMid slice" focusable= "false" role= "img" { % i f t i t l e ! = ' ' o r t e x t ! = ' ' % } aria-label= "{% if title != ' ' %}{{ title }}{% if text != ' ' %}: {% endif %}{% endif %}{% if text != ' ' %}{{ text }}{% endif %}" { % e n d i f % } >
2018-11-12 21:54:33 +01:00
{% if title != ' ' %}<title > {{ title }}</title> {% endif %}
<rect fill= "{{ background }}" width= "100%" height= "100%" />
{% if text != ' ' %}<text fill= "{{ color }}" dy= ".3em" x= "50%" y= "50%" > {{ text }}</text> {% endif %}
</svg>
{%- endcapture -%}
2018-11-08 18:33:02 +01:00
2018-11-12 21:54:33 +01:00
{{- svg | replace: ' ', '' | strip_newlines -}}