feat(image): enhance image handling with new properties and responsive support
Deploy / verify (push) Successful in 41s
Deploy / deploy (push) Successful in 1m2s

- Updated PostEntry type to include _rawImageUrl and _imageFocal for improved image management.
- Refactored image handling in various components to utilize the new properties, ensuring better focal point support and responsive image rendering.
- Introduced warmResponsiveImage function for pre-fetching image variants to optimize loading performance.
- Replaced CmsImage component with RustyImage in multiple blocks for consistent image processing.
This commit is contained in:
Peter Meier
2026-04-18 08:43:17 +02:00
parent 3c6ff773ae
commit a2f2d5bfb0
14 changed files with 297 additions and 162 deletions
+21 -4
View File
@@ -2,8 +2,13 @@
import type { PostEntry } from "$lib/cms";
import PostMeta from "./PostMeta.svelte";
import EventBadges from "./EventBadges.svelte";
import RustyImage from "./RustyImage.svelte";
type PostWithImage = PostEntry & { _resolvedImageUrl?: string };
type PostWithImage = PostEntry & {
_resolvedImageUrl?: string;
_rawImageUrl?: string;
_imageFocal?: { x: number; y: number } | null;
};
let {
post,
@@ -15,7 +20,9 @@
tagBase?: string;
} = $props();
const resolvedImg = $derived(post._resolvedImageUrl);
const rawImg = $derived(post._rawImageUrl);
const focal = $derived(post._imageFocal ?? null);
const fallbackImg = $derived(post._resolvedImageUrl);
type PostWithEvent = PostWithImage & {
isEvent?: boolean;
@@ -33,9 +40,19 @@
class="transition-all flex flex-col text-slate-950 no-underline overflow-hidden border border-gray-200 bg-white"
>
<div class="relative aspect-3/2 w-full overflow-hidden bg-gray-100">
{#if resolvedImg}
{#if rawImg}
<RustyImage
src={rawImg}
focal={focal}
width={400}
aspect="3/2"
alt={post.headline ?? ""}
class="w-full h-full object-cover"
loading="lazy"
/>
{:else if fallbackImg}
<img
src={resolvedImg}
src={fallbackImg}
alt={post.headline ?? ""}
class="w-full h-full object-cover"
loading="lazy"