<script lang="ts">
    import { apiBaseURL } from "../../config"

    export let collectionName: string = null
    export let entryId: string = null
    export let file: File = null
    export let alt: string = ""
    export let cssClass: string = ""
</script>

{#if collectionName && entryId && file}
    {#if file.src.includes(";base64,")}
        <img src="{file.src}" alt="{alt ? alt + ' - ' : ''}{file.path}" class="{cssClass}" />
    {:else}
        <img
            src="{`${apiBaseURL}${collectionName}/${entryId}/${file.src}?filter=l`}"
            alt="{alt ? alt : file.path}"
            class="{cssClass}"
        />
    {/if}
{/if}
