1
0
Fork 0
esix-client/src/lib/components/PostMedia.svelte
2024-10-23 23:21:27 +02:00

24 lines
713 B
Svelte

<script>
import useSettings from '$lib/useSettings.svelte.js';
const settings = useSettings();
/**
* @typedef {Object} Props
* @property {any} [post]
*/
/** @type {Props} */
let { post = null } = $props();
</script>
{#if post?.preview?.has}
<img class:max-h-dvh={settings.limitImageHeight} src={post.preview.url} alt={`Post ${post.id}`} />
{:else}
{#if ['webm', 'mp4'].includes(post.file.ext)}
<video class:max-h-dvh={settings.limitImageHeight} controls playsinline>
<source src={post.file.url} />
</video>
{:else}
<img class:max-h-dvh={settings.limitImageHeight} src={post.file.url} alt={`Post ${post.id}`} />
{/if}
{/if}