Skip to content

Commit

Permalink
Set all image sizes to small
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralf-Pauli committed Dec 18, 2024
1 parent 6859afb commit 383bd46
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
// Function to update category images with full URLs
function updateCategoryImages(categories: Array<{ image?: { url: string } }>) {
return categories.map((category) => {
const imageUrl = category.image?.url;
const imageUrl = category.image?.formats.small.url;
if (imageUrl) {
const fullUrl = imageUrl.startsWith("http") ? imageUrl : `${PUBLIC_STRAPI_HOST}${imageUrl}`;
const fullUrl = `${PUBLIC_STRAPI_HOST}${imageUrl}`;
return { ...category, image: { ...category.image, url: fullUrl } };
}
Expand Down
11 changes: 2 additions & 9 deletions src/routes/galerie/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,13 @@
import { PUBLIC_STRAPI_HOST } from "$env/static/public";
export let data: PageData;
const allImages = data.images.map((image: any) => ({
alt: image.alternativeText,
src: PUBLIC_STRAPI_HOST + image.url,
height: image.height,
width: image.width,
}));
</script>

<div class="max-w-5xl mx-auto flex gap-20">
<div class="columns-1 md:columns-3 gap-6">
{#each allImages as image}
{#each data.images as image}
<div class="p-3 md:p-0">
<img class="md:mb-6 rounded-xl" src={image.src} alt={image.alt} />
<img class="md:mb-6 rounded-xl" src={PUBLIC_STRAPI_HOST + image.formats.small.url} alt={image.alt} />
</div>
{/each}
</div>
Expand Down

0 comments on commit 383bd46

Please sign in to comment.