{# Media preview component for videos, images, and audio. Usage: {% from "components/media_preview.html" import media_preview, video_player, image_preview, audio_player %} {{ media_preview(content_hash, media_type, title="Preview") }} {{ video_player(src="/cache/abc123/mp4", poster="/cache/abc123/thumb") }} #} {% macro media_preview(content_hash, media_type, title=None, class="", show_download=True) %}
{% if title %}

{{ title }}

{% endif %}
{% if media_type == "video" %} {{ video_player("/cache/" + content_hash + "/mp4") }} {% elif media_type == "image" %} {{ image_preview("/cache/" + content_hash + "/raw") }} {% elif media_type == "audio" %} {{ audio_player("/cache/" + content_hash + "/raw") }} {% else %}

Preview not available

{% endif %}
{% if show_download %}
Download original
{% endif %}
{% endmacro %} {% macro video_player(src, poster=None, autoplay=False, muted=True, loop=False, class="") %} {% endmacro %} {% macro image_preview(src, alt="", class="") %} {{ alt }} {% endmacro %} {% macro audio_player(src, class="") %}
{% endmacro %} {% macro thumbnail(content_hash, media_type, size="w-24 h-24", class="") %}
{% if media_type == "image" %} {% elif media_type == "video" %} {% elif media_type == "audio" %} {% else %} {% endif %}
{% endmacro %}