-
Hi, I played around with the
As I know about the layout of the page, I want to wrap this in an image component // Image.vue
// Usage (pseudo code):
// <Image :src="frontmatter.desktop_image" :mobileSrc="frontmatter.mobile_image"/>
<script setup lang="ts">
const { src, mobileSrc } = defineProps<{
src: string;
mobileSrc?: string;
}>();
const parsedMobileSrc = $computed(() => mobileSrc || src);
const mobile = $computed(() => `${parsedMobileSrc}?preset=mobile&src`);
const tablet = $computed(() => `${src}?preset=tablet&src`);
</script>
<template>
<ResponsiveImage
:src="src"
:mobile="mobile"
:tablet="tablet"
sizes="(max-width: 500px) 100vw, (max-width: 800px) calc(100vw - 20px)"
/>
</template> // ResponsiveImage
// just builds the source set with the different image URLs and renders an Img tag My problem is that the
I tried to add this to the vue: {
template: {
transformAssetUrls: {
tags: {
ResponsiveImage: ["src", "mobile", "tablet"],
},
},
},
}, Any tips or hints how to make this work in my dynamic setup are very much appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi Robert! See this answer for a general overview of ways to reference images. The |
Beta Was this translation helpful? Give feedback.
Hi Robert!
See this answer for a general overview of ways to reference images.
The
resolveImage
programmatic API invite-plugin-image-presets
can apply presets to a dynamic path, and you can use it inextendFrontmatter
.