@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/node/index.mjs
CHANGED
|
@@ -833,15 +833,31 @@ function img(el, state, forApp = true) {
|
|
|
833
833
|
return;
|
|
834
834
|
}
|
|
835
835
|
el.setAttribute("itemprop", "image");
|
|
836
|
-
const
|
|
837
|
-
|
|
836
|
+
const avatarRoute = new RegExp(`^${trimTrailingSlash(getProxyBase()).replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}/u/[^/]+/avatar(?:/[a-z]+)?$`);
|
|
837
|
+
const classTokens = (el.getAttribute("class") || "").split(/\s+/);
|
|
838
|
+
const isAvatar = avatarRoute.test(decodedSrc) || classTokens.includes("er-author-link-image");
|
|
839
|
+
if (isAvatar) {
|
|
840
|
+
el.setAttribute("loading", "lazy");
|
|
841
|
+
el.setAttribute("decoding", "async");
|
|
842
|
+
}
|
|
843
|
+
const imageIndex = !state || isAvatar ? 3 : state.imageCount ?? (state.firstImageFound ? 1 : 0);
|
|
844
|
+
if (state && !isAvatar) {
|
|
845
|
+
state.imageCount = imageIndex + 1;
|
|
846
|
+
state.firstImageFound = true;
|
|
847
|
+
}
|
|
848
|
+
if (isAvatar) ; else if (imageIndex === 0) {
|
|
838
849
|
el.setAttribute("loading", "eager");
|
|
839
850
|
el.setAttribute("fetchpriority", "high");
|
|
840
|
-
|
|
851
|
+
} else if (imageIndex === 1) {
|
|
852
|
+
el.setAttribute("loading", "eager");
|
|
853
|
+
el.setAttribute("decoding", "async");
|
|
841
854
|
} else {
|
|
842
855
|
el.setAttribute("loading", "lazy");
|
|
843
856
|
el.setAttribute("decoding", "async");
|
|
844
857
|
}
|
|
858
|
+
if (isAvatar || imageIndex !== 0) {
|
|
859
|
+
el.removeAttribute("fetchpriority");
|
|
860
|
+
}
|
|
845
861
|
const cls = el.getAttribute("class") || "";
|
|
846
862
|
const shouldReplace = !cls.includes("no-replace");
|
|
847
863
|
const base = trimTrailingSlash(getProxyBase());
|