16 lines
464 B
TypeScript
16 lines
464 B
TypeScript
"use client"
|
|
|
|
import NextImage from "next/image"
|
|
|
|
import type { ImageLoaderProps, ImageProps } from "next/image"
|
|
|
|
function imageLoader({ quality, src, width }: ImageLoaderProps) {
|
|
const hasQS = src.indexOf("?") !== -1
|
|
return `${src}${hasQS ? "&" : "?"}w=${width}${quality ? "&q=" + quality : ""}`
|
|
}
|
|
|
|
// Next/Image adds & instead of ? before the params
|
|
export default function Image(props: ImageProps) {
|
|
return <NextImage {...props} loader={imageLoader} />
|
|
}
|