...
|
...
|
@@ -34,9 +34,13 @@ const imgSrcHandle = (imgUrl, params) => { |
|
|
imgUrl = imgUrl.replace(/\/q\/\d+/g, '/q/' + params.q);
|
|
|
}
|
|
|
|
|
|
if (window.supportWebp && !/format\//.test(imgUrl)) {
|
|
|
if (window.supportWebp && !/format\//i.test(query)) {
|
|
|
imgUrl += '/format/webp';
|
|
|
}
|
|
|
|
|
|
if (window.supportWebp && (/format\/png/i.test(query) || /format\/jpg/i.test(query))) {
|
|
|
imgUrl = imgUrl.replace(/format\/png/i, 'format/webp').replace(/format\/jpg/i, 'format/webp');
|
|
|
}
|
|
|
} else if (/imageMogr2/.test(query)) {
|
|
|
if (!/\/quality\/\d+/.test(imgUrl)) {
|
|
|
imgUrl += `/quality/${params.q}`;
|
...
|
...
|
@@ -47,6 +51,10 @@ const imgSrcHandle = (imgUrl, params) => { |
|
|
if (window.supportWebp && !/format\//.test(imgUrl)) {
|
|
|
imgUrl += '/format/webp';
|
|
|
}
|
|
|
|
|
|
if (window.supportWebp && (/format\/png/i.test(query) || /format\/jpg/i.test(query))) {
|
|
|
imgUrl = imgUrl.replace(/format\/png/i, 'format/webp').replace(/format\/jpg/i, 'format/webp');
|
|
|
}
|
|
|
}
|
|
|
return imgUrl;
|
|
|
};
|
...
|
...
|
|