diff --git a/bun.lockb b/bun.lockb
index 7b010a6..b898e46 100755
Binary files a/bun.lockb and b/bun.lockb differ
diff --git a/package.json b/package.json
index cc5b2e9..ebfe864 100644
--- a/package.json
+++ b/package.json
@@ -17,6 +17,7 @@
"eslint-config-prettier": "9.1.2",
"eslint-plugin-svelte": "2.46.1",
"husky": "^9.1.7",
+ "image-size": "^2.0.2",
"jsdom": "^29.1.1",
"lint-staged": "^17.0.8",
"postcss": "^8.4.38",
diff --git a/src/lib/components/ImageLoader.svelte b/src/lib/components/ImageLoader.svelte
new file mode 100644
index 0000000..1307c2a
--- /dev/null
+++ b/src/lib/components/ImageLoader.svelte
@@ -0,0 +1,46 @@
+
+
+
+
+ {#if !loaded}
+
+ {/if}
+
+
+

+
diff --git a/src/lib/helpers/projectsProvider.ts b/src/lib/helpers/projectsProvider.ts
index 73d9e9f..377976d 100644
--- a/src/lib/helpers/projectsProvider.ts
+++ b/src/lib/helpers/projectsProvider.ts
@@ -4,6 +4,7 @@ import Pen from 'svelte-material-icons/Pen.svelte';
import Web from 'svelte-material-icons/Web.svelte';
import Youtube from 'svelte-material-icons/Youtube.svelte';
import { FunProject, LinkWithIcon, ResearchProject } from '../types';
+import imageDimensions from 'virtual:image-dimensions';
let cachedResearchProjects: ResearchProject[] | null = null;
@@ -400,6 +401,9 @@ export function getResearchProjects(): ResearchProject[] {
)
];
projects.sort((a, b) => parseInt(b.year) - parseInt(a.year));
+ projects.forEach((p) => {
+ if (imageDimensions[p.imageSrc]) p.imageDimensions = imageDimensions[p.imageSrc];
+ });
cachedResearchProjects = projects;
return projects;
}
@@ -505,6 +509,9 @@ export function getFunProjects(): FunProject[] {
]
)
];
+ projects.forEach((p) => {
+ if (imageDimensions[p.imageSrc]) p.imageDimensions = imageDimensions[p.imageSrc];
+ });
cachedFunProjects = projects;
return projects;
}
diff --git a/src/lib/types.ts b/src/lib/types.ts
index f570f96..e767774 100644
--- a/src/lib/types.ts
+++ b/src/lib/types.ts
@@ -24,6 +24,7 @@ export class Project {
title: string;
abstract: string;
imageSrc: string;
+ imageDimensions?: { width: number; height: number };
links: LinkWithIcon[];
/**
* Creates a project
@@ -32,11 +33,19 @@ export class Project {
* @param {String} abstract the abstract of the project/paper
* @param {String} imageSrc the image source for the project
* @param {[LinkWithIcon]} links links from the project to more information
+ * @param {{ width: number; height: number }} imageDimensions dimensions of the image
*/
- constructor(title: string, abstract: string, imageSrc: string, links: LinkWithIcon[] = []) {
+ constructor(
+ title: string,
+ abstract: string,
+ imageSrc: string,
+ links: LinkWithIcon[] = [],
+ imageDimensions?: { width: number; height: number }
+ ) {
this.title = title;
this.abstract = abstract;
this.imageSrc = imageSrc;
+ this.imageDimensions = imageDimensions;
this.links = links;
}
}
@@ -59,6 +68,7 @@ export class ResearchProject extends Project {
* @param {String} venue the venue of the publication
* @param {String} imageSRC the image source for the project
* @param {[LinkWithIcon]} links links from the project to more information
+ * @param {{ width: number; height: number }} imageDimensions dimensions of the image
*/
constructor(
title: string,
@@ -67,9 +77,10 @@ export class ResearchProject extends Project {
year: string,
venue: string,
imageSRC: string,
- links: LinkWithIcon[] = []
+ links: LinkWithIcon[] = [],
+ imageDimensions?: { width: number; height: number }
) {
- super(title, abstract, imageSRC, links);
+ super(title, abstract, imageSRC, links, imageDimensions);
this.authors = authors;
this.year = year;
this.venue = venue;
@@ -87,9 +98,16 @@ export class FunProject extends Project {
* @param {String} abstract the abstract of the project/paper
* @param {String} imageSRC the image source for the project
* @param {[LinkWithIcon]} links links from the project to more information
+ * @param {{ width: number; height: number }} imageDimensions dimensions of the image
*/
- constructor(title: string, abstract: string, imageSRC: string, links: LinkWithIcon[] = []) {
- super(title, abstract, imageSRC, links);
+ constructor(
+ title: string,
+ abstract: string,
+ imageSRC: string,
+ links: LinkWithIcon[] = [],
+ imageDimensions?: { width: number; height: number }
+ ) {
+ super(title, abstract, imageSRC, links, imageDimensions);
}
}
diff --git a/src/routes/publications/+page.svelte b/src/routes/publications/+page.svelte
index d0c1f6b..cab3259 100644
--- a/src/routes/publications/+page.svelte
+++ b/src/routes/publications/+page.svelte
@@ -1,5 +1,6 @@