Skip to content

Commit 6928254

Browse files
committed
improve image embed
1 parent 5ae18cc commit 6928254

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

_includes/embed_image.html

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,33 @@
1+
{% comment %}
2+
TRUE VERSUS "TRUE"
3+
Some attributes can be set by passing the string "true" into this template.
4+
For example, the thumbnail attribute. That is why some comparisons use the
5+
language builtin true and others compare to the string "true".
6+
{% endcomment %}
7+
18
{%- assign img-style = false -%}
9+
{%- assign img-link = false -%}
210

311
{%- if include.width or include.height -%}
412
{%- assign img-style = true -%}
513
{%- endif -%}
614

15+
{%- if include.link -%}
16+
{%- assign img-link = include.link -%}
17+
{%- elseif include.thumbnail == "true" -%}
18+
{%- capture img-link -%}{{ site.baseurl }}/{{ include.url }}{%- endcapture -%}
19+
{%- endif -%}
20+
{% comment %}
21+
If the link parameter is used, the URL will be set to its contents. If the
22+
thumbnail parameter has been used, the URL will automatically be set to the original
23+
image. Otherwise, no link will be generated for the image.
24+
{% endcomment %}
25+
726
{% if include.caption %}
827
<figure class="caption-image {% if include.thumbnail == "true" %} thumbnail{%- endif -%}">
928
{%- endif -%}
10-
{%- if include.link -%}
11-
<a href="{{- include.link -}}">
12-
{%- elsif include.thumbnail == "true" -%}
13-
<a href="{{ site.baseurl }}/{{ include.url }}">
29+
{%- if img-link -%}
30+
<a href="{{- img-link -}}">
1431
{%- endif -%}
1532
<img
1633
src="{{ site.baseurl }}/{{ include.url }}"
@@ -20,7 +37,7 @@
2037
style="{%- if include.width -%}width: {{- include.width -}};{%- endif -%}{%- if include.height -%}height: {{- include.height -}};{%- endif -%}"
2138
{% endif -%}
2239
>
23-
{%- if include.link or include.thumbnail -%}
40+
{%- if img-link -%}
2441
</a>
2542
{%- endif -%}
2643
{% if include.caption %}

0 commit comments

Comments
 (0)