aboutsummaryrefslogtreecommitdiff
path: root/site/_includes
diff options
context:
space:
mode:
authorXhmikosR <[email protected]>2018-11-12 22:54:33 +0200
committerXhmikosR <[email protected]>2018-11-20 21:31:28 +0200
commit2ac3db83848ec94e7acd0f6c1e9b1bca4a3aa6b3 (patch)
tree91e5fbe71bf04cb062c9744f9ae5d3926e219e5b /site/_includes
parent072b5ab7fd59ff6ad16495a557a07d7b31c992a6 (diff)
downloadbootstrap-2ac3db83848ec94e7acd0f6c1e9b1bca4a3aa6b3.tar.xz
bootstrap-2ac3db83848ec94e7acd0f6c1e9b1bca4a3aa6b3.zip
Tweak placeholder.svg.
* always include the title * make it possible to skip adding the title by passing `title=' '` * remove viewBox since we don't need it
Diffstat (limited to 'site/_includes')
-rw-r--r--site/_includes/icons/placeholder.svg57
1 files changed, 28 insertions, 29 deletions
diff --git a/site/_includes/icons/placeholder.svg b/site/_includes/icons/placeholder.svg
index a6f835d8e..03f06c048 100644
--- a/site/_includes/icons/placeholder.svg
+++ b/site/_includes/icons/placeholder.svg
@@ -1,36 +1,35 @@
-{%- if include.width -%}
- {% assign width = include.width %}
-{%- else -%}
- {% assign width = '100%' %}
-{%- endif -%}
-
-{%- if include.height -%}
- {% assign height = include.height %}
-{%- else -%}
- {% assign height = 180 %}
-{%- endif -%}
+{%- comment -%}
+ Usage: include icons/placeholder.svg args
-{%- if include.text -%}
- {% assign text = include.text %}
-{%- else -%}
- {% assign text = width | append: 'x' | append: height %}
-{%- endif -%}
+ 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'
+ color: The text color (foreground) - default: '#ddd'
+ background: The background color - default: '#777'
+ width: default: 100%
+ height: default: 180px
+{%- endcomment -%}
-{%- if include.class -%}
- {% assign class = include.class| prepend: ' ' %}
-{%- endif -%}
+{%- assign title = include.title | default: 'Generic Placeholder Image' -%}
+{%- assign class = include.class | default: '' -%}
+{%- assign color = include.color | default: '#ddd' -%}
+{%- assign background = include.background | default: '#777' -%}
+{%- assign width = include.width | default: '100%' -%}
+{%- assign height = include.height | default: '180' -%}
-{%- if include.color -%}
- {% assign color = include.color %}
+{%- if include.text -%}
+ {%- assign text = include.text -%}
{%- else -%}
- {% assign color = '#ddd' %}
+ {%- assign text = width | append: 'x' | append: height -%}
{%- endif -%}
-{%- if include.background -%}
- {% assign background = include.background %}
-{%- else -%}
- {% assign background = '#777' %}
-{%- endif -%}
+{%- capture svg -%}
+<svg class="bd-placeholder-img{% if class != '' %} {{ class }}{% endif %}" width="{{ width }}" height="{{ height }}" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid slice">
+ {% 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 -%}
-<svg class="bd-placeholder-img{{ class }}" width="{{ width }}" height="{{ height }}" xmlns="http://www.w3.org/2000/svg"{% if include.viewBox %} viewBox="{{ include.viewBox }}"{% endif %} preserveAspectRatio="xMidYMid slice">{% if include.title %}<title>{{ include.title }}</title>{% endif %}<rect fill="{{ background }}" width="100%" height="100%" /><text x="50%" y="50%" dy=".3em" fill="{{ color }}">{{ text }}</text></svg>
-{{- '' -}}
+{{- svg | replace: ' ', '' | strip_newlines -}}