@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.
@@ -860,15 +860,31 @@ function img(el, state, forApp = true) {
860
860
  return;
861
861
  }
862
862
  el.setAttribute("itemprop", "image");
863
- const isLCP = state && !state.firstImageFound;
864
- if (isLCP) {
863
+ const avatarRoute = new RegExp(`^${trimTrailingSlash(getProxyBase()).replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}/u/[^/]+/avatar(?:/[a-z]+)?$`);
864
+ const classTokens = (el.getAttribute("class") || "").split(/\s+/);
865
+ const isAvatar = avatarRoute.test(decodedSrc) || classTokens.includes("er-author-link-image");
866
+ if (isAvatar) {
867
+ el.setAttribute("loading", "lazy");
868
+ el.setAttribute("decoding", "async");
869
+ }
870
+ const imageIndex = !state || isAvatar ? 3 : state.imageCount ?? (state.firstImageFound ? 1 : 0);
871
+ if (state && !isAvatar) {
872
+ state.imageCount = imageIndex + 1;
873
+ state.firstImageFound = true;
874
+ }
875
+ if (isAvatar) ; else if (imageIndex === 0) {
865
876
  el.setAttribute("loading", "eager");
866
877
  el.setAttribute("fetchpriority", "high");
867
- state.firstImageFound = true;
878
+ } else if (imageIndex === 1) {
879
+ el.setAttribute("loading", "eager");
880
+ el.setAttribute("decoding", "async");
868
881
  } else {
869
882
  el.setAttribute("loading", "lazy");
870
883
  el.setAttribute("decoding", "async");
871
884
  }
885
+ if (isAvatar || imageIndex !== 0) {
886
+ el.removeAttribute("fetchpriority");
887
+ }
872
888
  const cls = el.getAttribute("class") || "";
873
889
  const shouldReplace = !cls.includes("no-replace");
874
890
  const base = trimTrailingSlash(getProxyBase());