@ecency/render-helper 2.5.29 → 2.5.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.js +19 -3
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +19 -3
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.mjs +19 -3
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.js
CHANGED
|
@@ -835,15 +835,31 @@ function img(el, state, forApp = true) {
|
|
|
835
835
|
return;
|
|
836
836
|
}
|
|
837
837
|
el.setAttribute("itemprop", "image");
|
|
838
|
-
const
|
|
839
|
-
|
|
838
|
+
const avatarRoute = new RegExp(`^${trimTrailingSlash(getProxyBase()).replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}/u/[^/]+/avatar(?:/[a-z]+)?$`);
|
|
839
|
+
const classTokens = (el.getAttribute("class") || "").split(/\s+/);
|
|
840
|
+
const isAvatar = avatarRoute.test(decodedSrc) || classTokens.includes("er-author-link-image");
|
|
841
|
+
if (isAvatar) {
|
|
842
|
+
el.setAttribute("loading", "lazy");
|
|
843
|
+
el.setAttribute("decoding", "async");
|
|
844
|
+
}
|
|
845
|
+
const imageIndex = !state || isAvatar ? 3 : state.imageCount ?? (state.firstImageFound ? 1 : 0);
|
|
846
|
+
if (state && !isAvatar) {
|
|
847
|
+
state.imageCount = imageIndex + 1;
|
|
848
|
+
state.firstImageFound = true;
|
|
849
|
+
}
|
|
850
|
+
if (isAvatar) ; else if (imageIndex === 0) {
|
|
840
851
|
el.setAttribute("loading", "eager");
|
|
841
852
|
el.setAttribute("fetchpriority", "high");
|
|
842
|
-
|
|
853
|
+
} else if (imageIndex === 1) {
|
|
854
|
+
el.setAttribute("loading", "eager");
|
|
855
|
+
el.setAttribute("decoding", "async");
|
|
843
856
|
} else {
|
|
844
857
|
el.setAttribute("loading", "lazy");
|
|
845
858
|
el.setAttribute("decoding", "async");
|
|
846
859
|
}
|
|
860
|
+
if (isAvatar || imageIndex !== 0) {
|
|
861
|
+
el.removeAttribute("fetchpriority");
|
|
862
|
+
}
|
|
847
863
|
const cls = el.getAttribute("class") || "";
|
|
848
864
|
const shouldReplace = !cls.includes("no-replace");
|
|
849
865
|
const base = trimTrailingSlash(getProxyBase());
|