Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/lib/common/FileGallery.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script>
import { PDF_ICON, isPdf } from '$lib/helpers/utils/file';
import { LightboxGallery, GalleryThumbnail, GalleryImage } from 'svelte-lightbox';

/** @type {any[]} */
Expand Down Expand Up @@ -56,7 +57,11 @@
<i class="bx bx-trash" />
</div>
{/if}
<img class="gallery-item-image" src={file.file_data} alt={''}>
{#if isPdf(file.file_type || file.file_name)}
<img class="gallery-item-image" src={PDF_ICON} alt={''}>
{:else}
<img class="gallery-item-image" src={file.file_data} alt={''}>
{/if}
</div>
</GalleryThumbnail>
</div>
Expand All @@ -65,9 +70,13 @@

{#each files as file, idx (idx)}
<GalleryImage title={file.file_name}>
<img src={file.file_data} alt={''} />
{#if isPdf(file.file_type || file.file_name)}
<img src={PDF_ICON} alt={''} />
{:else}
<img src={file.file_data} alt={''} />
{/if}
{#if !!file.file_name}
<div class="item-text">{file.file_name}</div>
<div class="item-text">{file.file_name}</div>
{/if}
</GalleryImage>
{/each}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/common/HeadTitle.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script>
import {PUBLIC_FAVICON_URL, PUBLIC_BRAND_NAME} from '$env/static/public'
export let title = 'Home';
export let addOn = 'Admin & Dashboard';
export let addOn = 'Dashboard';
</script>

<svelte:head>
Expand Down
7 changes: 7 additions & 0 deletions src/lib/helpers/utils/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,11 @@ export function getBase64(file) {
reader.onload = () => resolve(reader.result);
reader.onerror = error => reject(error);
});
}

export const PDF_ICON = 'images/icons/pdf_icon.jpg';

/** @param {string | undefined} file */
export function isPdf(file) {
return file?.endsWith('pdf') || false;
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<ul class="list-inline mb-0">
<li class="list-inline-item">
<FileDropZone
accept="image/*"
accept="image/*,.pdf"
disableDefaultStyles
noDrag
disabled={disableFileDrop}
Expand Down
Binary file added static/images/icons/pdf_icon.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.