Skip to content

Commit bee1eb9

Browse files
committed
lazyImage-w
1 parent f037a41 commit bee1eb9

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

components/LazyImage.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,11 @@ const adjustImgSize = (src, maxWidth) => {
128128

129129
// 正则表达式,用于匹配 URL 中的 width 参数
130130
const widthRegex = /width=\d+/
131-
// 使用正则表达式替换 width 参数
132-
return src.replace(widthRegex, `width=${screenWidth}`)
131+
// 正则表达式,用于匹配 URL 中的 w 参数
132+
const wRegex = /w=\d+/
133+
134+
// 使用正则表达式替换 width/w 参数
135+
return src
136+
.replace(widthRegex, `width=${screenWidth}`)
137+
.replace(wRegex, `w=${screenWidth}`)
133138
}

0 commit comments

Comments
 (0)