-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloader.js
More file actions
27 lines (19 loc) · 749 Bytes
/
loader.js
File metadata and controls
27 lines (19 loc) · 749 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
"use client";
import { env } from "@/env";
export default function myImageLoader({ src, width, quality }) {
const isLocal = !src.startsWith("http");
const query = new URLSearchParams();
const imageOptimizationApi = "https://images.mkutay.dev";
// Your NextJS application URL
const baseUrl = "https://kcldnd.uk";
const fullSrc = `${baseUrl}${src}`;
if (width) query.set("width", width);
if (quality) query.set("quality", quality);
if (env.NEXT_PUBLIC_NODE_ENV === "development" || env.NEXT_PUBLIC_SITE_URL === "http://localhost:3000") {
return src;
}
if (isLocal) {
return `${imageOptimizationApi}/image/${fullSrc}?${query.toString()}`;
}
return `${imageOptimizationApi}/image/${src}?${query.toString()}`;
}