UNPKG

@nuxt/image

Version:

Nuxt Image Module

23 lines (22 loc) 596 B
import { joinURL } from "ufo"; import { createOperationsGenerator } from "../utils/index.js"; import { defineProvider } from "../utils/provider.js"; const operationsGenerator = createOperationsGenerator({ valueMap: { fit: { fill: "crop", inside: "crop", outside: "crop", cover: "bounds", contain: "bounds" } } }); export default defineProvider({ getImage: (src, { modifiers, baseURL = "/" }) => { const operations = operationsGenerator(modifiers); return { url: joinURL(baseURL, src + (operations ? "?" + operations : "")) }; } });