@nuxt/image
Version:
Nuxt Image Module
29 lines (28 loc) • 872 B
JavaScript
import { computed } from "vue";
import { parseSize } from "./index.js";
import { useImage } from "#imports";
export const useImageProps = (props) => {
const $img = useImage();
const providerOptions = computed(() => ({
provider: props.provider,
preset: props.preset
}));
const normalizedAttrs = computed(() => ({
width: parseSize(props.width),
height: parseSize(props.height),
crossorigin: props.crossorigin === true ? "anonymous" : props.crossorigin || void 0,
nonce: props.nonce
}));
const imageModifiers = computed(() => {
return {
...props.modifiers,
width: props.width,
height: props.height,
format: props.format,
quality: props.quality || $img.options.quality,
background: props.background,
fit: props.fit
};
});
return { providerOptions, normalizedAttrs, imageModifiers };
};