Skip to content

Commit 46f346d

Browse files
authored
add wake optimization for images (#1501)
* add wake optimization for images * fmt
1 parent 2b0d583 commit 46f346d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

website/components/Image.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,16 @@ const optimizeVTEX = (opts: OptimizationOptions) => {
104104
return src.href;
105105
};
106106

107+
const optimizeWake = (opts: OptimizationOptions) => {
108+
const { originalSrc, width, height } = opts;
109+
110+
const url = new URL(originalSrc);
111+
url.searchParams.set("w", `${width}`);
112+
url.searchParams.set("h", `${height}`);
113+
114+
return url.href;
115+
};
116+
107117
export const getOptimizedMediaUrl = (opts: OptimizationOptions) => {
108118
const { originalSrc, width, height, fit } = opts;
109119

@@ -112,6 +122,10 @@ export const getOptimizedMediaUrl = (opts: OptimizationOptions) => {
112122
}
113123

114124
if (!isImageOptmizationEnabled()) {
125+
if (originalSrc.includes("fbitsstatic.net/img/")) {
126+
return optimizeWake(opts);
127+
}
128+
115129
if (originalSrc.startsWith("https://cdn.vnda.")) {
116130
return optmizeVNDA(opts);
117131
}

0 commit comments

Comments
 (0)