{% extends "layout.html" %} {# ================================================================== #} {# MACRO QUI GENERE LE TAG PICTURE #} {# ================================================================== #} {% macro responsive_image(image_info, alt_text) %} {% set image_path_prefix = url_for('static', filename='images/') %} {% set webp_sources = [] %} {% set png_sources = [] %} {% for deriv in image_info.derivatives %} {% if 'webp' in deriv.formats %}{% set _ = webp_sources.append(image_path_prefix + deriv.formats.webp + ' ' + deriv.width ~ 'w') %}{% endif %} {% if 'png' in deriv.formats %}{% set _ = png_sources.append(image_path_prefix + deriv.formats.png + ' ' + deriv.width ~ 'w') %}{% endif %} {% endfor %} {% set webp_srcset = webp_sources | join(', ') %} {% set png_srcset = png_sources | join(', ') %} {% set fallback_image = image_info.derivatives[0] if image_info.derivatives else none %} {% if fallback_image %} {% set style_str = "aspect-ratio: {} / {};".format(fallback_image.width, fallback_image.height) %} {% if webp_srcset %}{% endif %} {% if png_srcset %}{% endif %} {{ alt_text }} {% endif %} {% endmacro %} {# ================================================================== #} {# CONTENU PRINCIPAL DE LA PAGE #} {# ================================================================== #} {% block content %} {% if error_message %} {% elif structured_images %}
{% for image_data in structured_images.values() %}
{{ responsive_image(image_data, 'Image de ' + image_data.base_name) }}

{{ image_data.base_name }}

{% endfor %}
{% else %} {% endif %} {% endblock %}