2023-02-01 17:58:59 +00:00
|
|
|
{% extends "base.html" %}
|
|
|
|
|
2023-02-12 19:09:36 +00:00
|
|
|
|
|
|
|
{% macro image(path, src, alt, class="") %}
|
|
|
|
<img alt="{{ alt }}" title="{{ alt }}" src="{{ get_url(path=path ~ src) | safe }}" class="{{ class }}" />
|
|
|
|
{% endmacro image %}
|
|
|
|
|
2023-02-01 17:58:59 +00:00
|
|
|
{#
|
|
|
|
Original author: crepererum https://github.com/getzola/even/pull/48/files
|
|
|
|
Adapted to Inky template by jimmyff
|
|
|
|
#}
|
|
|
|
|
2023-02-12 19:09:36 +00:00
|
|
|
{% macro responsive_image(path, src, alt, default_size, sizes, class="") %}
|
2023-02-01 17:58:59 +00:00
|
|
|
{% if config.extra.image_resizing_disabled and config.extra.image_resizing_disabled == true %}
|
2023-02-12 19:09:36 +00:00
|
|
|
{{ image(path=path, src=src, alt=alt, class=class) }}
|
2023-02-01 17:58:59 +00:00
|
|
|
{% else %}
|
2023-02-12 19:09:36 +00:00
|
|
|
{% set abspath = path ~ src %}
|
2023-02-01 17:58:59 +00:00
|
|
|
{% set meta = get_image_metadata(path=abspath) %}
|
|
|
|
{% set width = meta.width %}
|
|
|
|
{% set srcset_list = [] %}
|
|
|
|
{% for s in sizes %}
|
|
|
|
{% if width >= s %}
|
|
|
|
{% set resized = resize_image(format=config.extra.image_format, path=abspath, width=s, op="fit_width", quality=config.extra.image_quality) %}
|
|
|
|
{% set element = resized.url ~ " " ~ s ~ "w" %}
|
|
|
|
{% set_global srcset_list = srcset_list | concat(with=[element]) %}
|
|
|
|
{% endif %}
|
|
|
|
{% endfor %}
|
|
|
|
{% set default_resized = resize_image(format=config.extra.image_format, path=abspath, width=default_size, op="fit_width", quality=config.extra.image_quality) %}
|
2023-02-12 19:09:36 +00:00
|
|
|
<img alt="{{ alt }}" title="{{ alt }}" src="{{ default_resized.url | safe }}" srcset="{{ srcset_list | join(sep=", ") | safe }}" class="{{ class }}" />
|
2023-02-01 17:58:59 +00:00
|
|
|
{% endif %}
|
|
|
|
{% endmacro responsive_image %}
|
|
|
|
|
|
|
|
|
2023-02-12 19:09:36 +00:00
|
|
|
{% macro responsive_thumbnail(path, src, alt, default_size, sizes, class="") %}
|
2023-02-01 17:58:59 +00:00
|
|
|
{% if config.extra.image_resizing_disabled and config.extra.image_resizing_disabled == true %}
|
2023-02-12 19:09:36 +00:00
|
|
|
{{ image(path=path, src=src, alt=alt, class=class) }}
|
2023-02-01 17:58:59 +00:00
|
|
|
{% else %}
|
2023-02-12 19:09:36 +00:00
|
|
|
{% set abspath = path ~ src %}
|
2023-02-01 17:58:59 +00:00
|
|
|
{% set meta = get_image_metadata(path=abspath) %}
|
|
|
|
{% set width = meta.width %}
|
|
|
|
{% set srcset_list = [] %}
|
|
|
|
{% for s in sizes %}
|
|
|
|
{% if width >= s %}
|
|
|
|
{% set resized = resize_image(format=config.extra.image_format, path=abspath, width=s, height=s, op="fill", quality=config.extra.thumbnail_quality) %}
|
|
|
|
{% set element = resized.url ~ " " ~ s ~ "w" %}
|
|
|
|
{% set_global srcset_list = srcset_list | concat(with=[element]) %}
|
|
|
|
{% endif %}
|
|
|
|
{% endfor %}
|
|
|
|
{% set default_resized = resize_image(format=config.extra.image_format, path=abspath, width=default_size, height=default_size, op="fill", quality=config.extra.thumbnail_quality) %}
|
2023-02-12 19:09:36 +00:00
|
|
|
<img alt="{{ alt }}" title="{{ alt }}" src="{{ default_resized.url | safe }}" srcset="{{ srcset_list | join(sep=", ") | safe }}" class="{{ class }}" />
|
2023-02-01 17:58:59 +00:00
|
|
|
{% endif %}
|
|
|
|
{% endmacro responsive_thumbnail %}
|