Attempt to fix relative img path bug

This commit is contained in:
Erica Marigold 2024-07-06 21:13:51 +05:30
parent 40f3fb1c8e
commit 472cba451a
No known key found for this signature in database
GPG key ID: 2768CC0C23D245D1

View file

@ -22,7 +22,7 @@ const isLocal = !(
src.startsWith("https") || src.startsWith("https") ||
src.startsWith("data:") src.startsWith("data:")
); );
const isPublic = src.startsWith("/"); // const isPublic = src.startsWith("/");
// TODO temporary workaround for images dynamic import // TODO temporary workaround for images dynamic import
// https://github.com/withastro/astro/issues/3373 // https://github.com/withastro/astro/issues/3373
@ -43,6 +43,6 @@ const imageStyle = `object-position: ${position}`;
<div id="image-wrapper" class:list={[className, 'overflow-hidden relative']}> <div id="image-wrapper" class:list={[className, 'overflow-hidden relative']}>
<div class="transition absolute inset-0 dark:bg-black/10 bg-opacity-50 pointer-events-none"></div> <div class="transition absolute inset-0 dark:bg-black/10 bg-opacity-50 pointer-events-none"></div>
{isLocal && <img src={optimizedImg!.src} alt={alt || ""} class={imageClass} style={imageStyle}/>} {isLocal && <img src={optimizedImg!.src} alt={alt || ""} class={imageClass} style={imageStyle}/>}
{!isLocal && <img src={isPublic ? url(src) : src} alt={alt || ""} class={imageClass} style={imageStyle}/>} {!isLocal && <img src={url(src)} alt={alt || ""} class={imageClass} style={imageStyle}/>}
</div> </div>