Docs: Fix resize_image and gallery shortcodes (#1543)
This commit is contained in:
parent
ee85300303
commit
96e28ddd5c
|
@ -127,7 +127,8 @@ but it can be used in Markdown using [shortcodes](@/documentation/content/shortc
|
||||||
The examples above were generated using a shortcode file named `resize_image.html` with this content:
|
The examples above were generated using a shortcode file named `resize_image.html` with this content:
|
||||||
|
|
||||||
```jinja2
|
```jinja2
|
||||||
<img src="{{ resize_image(path=path, width=width, height=height, op=op) }}" />
|
{% set image = resize_image(path=path, width=width, height=height, op=op) %}
|
||||||
|
<img src="{{ image.url }}" />
|
||||||
```
|
```
|
||||||
|
|
||||||
## Creating picture galleries
|
## Creating picture galleries
|
||||||
|
@ -143,14 +144,16 @@ This can be used in shortcodes. For example, we can create a very simple html-on
|
||||||
picture gallery with the following shortcode named `gallery.html`:
|
picture gallery with the following shortcode named `gallery.html`:
|
||||||
|
|
||||||
```jinja2
|
```jinja2
|
||||||
{% for asset in page.assets %}
|
<div>
|
||||||
{% if asset is matching("[.](jpg|png)$") %}
|
{% for asset in page.assets -%}
|
||||||
<a href="{{ get_url(path=asset) }}">
|
{%- if asset is matching("[.](jpg|png)$") -%}
|
||||||
<img src="{{ resize_image(path=asset, width=240, height=180, op="fill") }}" />
|
{% set image = resize_image(path=asset, width=240, height=180) %}
|
||||||
|
<a href="{{ get_url(path=asset) }}" target="_blank">
|
||||||
|
<img src="{{ image.url }}" />
|
||||||
</a>
|
</a>
|
||||||
 
|
{%- endif %}
|
||||||
{% endif %}
|
{%- endfor %}
|
||||||
{% endfor %}
|
</div>
|
||||||
```
|
```
|
||||||
|
|
||||||
As you can notice, we didn't specify an `op` argument, which means that it'll default to `"fill"`. Similarly,
|
As you can notice, we didn't specify an `op` argument, which means that it'll default to `"fill"`. Similarly,
|
||||||
|
|
7
docs/templates/shortcodes/gallery.html
vendored
7
docs/templates/shortcodes/gallery.html
vendored
|
@ -1,7 +1,10 @@
|
||||||
|
<div>
|
||||||
{% for asset in page.assets -%}
|
{% for asset in page.assets -%}
|
||||||
{%- if asset is matching("[.](jpg|png)$") -%}
|
{%- if asset is matching("[.](jpg|png)$") -%}
|
||||||
<a href="{{ get_url(path=asset) | safe }}" target="_blank">
|
{% set image = resize_image(path=asset, width=240, height=180) %}
|
||||||
<img src="{{ resize_image(path=asset, width=240, height=180, op="fill", format="auto") | safe }}" />
|
<a href="{{ get_url(path=asset) }}" target="_blank">
|
||||||
|
<img src="{{ image.url }}" />
|
||||||
</a>
|
</a>
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
|
</div>
|
||||||
|
|
3
docs/templates/shortcodes/resize_image.html
vendored
3
docs/templates/shortcodes/resize_image.html
vendored
|
@ -1 +1,2 @@
|
||||||
<img src="{{ resize_image(path=path, width=width, height=height, op=op) }}" />
|
{% set image = resize_image(path=path, width=width, height=height, op=op) %}
|
||||||
|
<img src="{{ image.url }}" />
|
||||||
|
|
Loading…
Reference in a new issue