From da1c0dd6c807b292d4ee83def75664d479620827 Mon Sep 17 00:00:00 2001 From: Stefan Imhoff Date: Sat, 24 Jan 2026 16:13:10 +0100 Subject: [PATCH] refactor: allow linking the image --- src/components/BasicImage.astro | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/components/BasicImage.astro b/src/components/BasicImage.astro index a13c5a1..ef2eaba 100644 --- a/src/components/BasicImage.astro +++ b/src/components/BasicImage.astro @@ -2,6 +2,7 @@ import { Picture } from 'astro:assets'; import type { ImageMetadata } from 'astro'; import TextLink from './TextLink.astro'; +import Link from './Link.astro'; interface Props { alt?: string; @@ -9,6 +10,7 @@ interface Props { class?: string; decoding?: 'async' | 'sync' | 'auto'; height?: string | number; + href?: string; loading?: 'lazy' | 'eager'; noSpacing?: boolean; quality?: number; @@ -25,6 +27,7 @@ const { class: className, decoding = 'async', height, + href, loading = 'lazy', noSpacing, quality, @@ -60,6 +63,10 @@ if (src.startsWith('/images')) { // Define sizes attribute for responsive images const sizes = '(max-width: 440px) 100vw, (max-width: 768px) 90vw, (max-width: 1024px) 85vw, 1100px'; + +// Determine the tag and specific attributes +const ImageWrapper = href ? Link : 'div'; +const wrapperProps = href ? { href } : {}; ---
) } - + { (caption || source) && (