Unfortunately, they aren't taking any PRs to add additional built-in loaders, but next/image is a popular component capable of using external resizing services to render an image.
Happy to do the PR if it's of interest. It should just be what follows, but I haven't properly tested yet.
import Image from 'next/image'
const normalizeSrc = (src: string): string => {
return src[0] === '/' ? src.slice(1) : src
}
const cloudflareLoader = ({ src, width, quality }) => {
const params = [`width=${width}`]
if (quality) {
params.push(`quality=${quality}`)
}
const paramsString = params.join(',')
return `/cdn-cgi/image/${paramsString}/${normalizeSrc(src)}`
}
const MyImage = (props) => {
return (
<Image
loader={myLoader}
src="/me.png"
alt="Picture of the author"
width={500}
height={500}
/>
)
}
Unfortunately, they aren't taking any PRs to add additional built-in loaders, but
next/imageis a popular component capable of using external resizing services to render an image.Happy to do the PR if it's of interest. It should just be what follows, but I haven't properly tested yet.