Skip to content

Commit

Permalink
feat(frontend): add unpic-img for image optimisation
Browse files Browse the repository at this point in the history
  • Loading branch information
jmiguelv committed Jul 11, 2024
1 parent 4d16ce2 commit c0b2136
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 34 deletions.
1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
},
"type": "module",
"dependencies": {
"@unpic/svelte": "^0.0.53",
"open-props": "^1.7.5",
"openseadragon": "^4.1.1"
}
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ export const url = dev ? 'http://localhost:5173/' : publicUrl;

export const imageServer =
'https://apheleia.classics.ox.ac.uk/iipsrv/iipsrv.fcgi?IIIF=inscription_images/';
export const imageThumbParams = 'full/400,/0/default.jpg';
14 changes: 7 additions & 7 deletions frontend/src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { page } from '$app/stores';
import BaseLink from '$lib/components/BaseLink.svelte';
import * as config from '$lib/config';
import { Image } from '@unpic/svelte';
import { onMount } from 'svelte';
/** @type {import('./$types').PageData} */
Expand Down Expand Up @@ -117,11 +118,12 @@
<li>
{#if inscription.facsimile}
<BaseLink href="inscription/{inscription.file}">
<img
<Image
src="{config.imageServer}{inscription.file}/{inscription.facsimile
.url}/full/400,/0/default.jpg"
.url}/{config.imageThumbParams}"
alt={inscription.facsimile.desc}
loading="lazy"
width={400}
height={200}
/>
</BaseLink>
{/if}
Expand Down Expand Up @@ -237,10 +239,8 @@
}
& img {
/* the height should be 200 */
height: 200px;
object-fit: cover;
width: 100%;
font-size: var(--font-size-1);
text-align: center;
}
}
}
Expand Down
65 changes: 38 additions & 27 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c0b2136

Please sign in to comment.