Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pages/cloudflare/howtos/image.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ const normalizeSrc = (src: string) => {
};

export default function cloudflareLoader({ src, width, quality }: ImageLoaderProps) {
if (process.env.NODE_ENV === "development") {
// Serve the original image when using `next dev`
return src;
}
const params = [`width=${width}`];
if (quality) {
params.push(`quality=${quality}`);
}
const paramsString = params.join(",");
if (process.env.NODE_ENV === "development") {
// Serve the original image when using `next dev`
return `${src}?${paramsString}`;
}
return `/cdn-cgi/image/${paramsString}/${normalizeSrc(src)}`;
}
```
Expand Down