Loading src/theme.cpp +13 −4 Changes for src/theme.cpp: 13 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -515,22 +515,31 @@ void blogi::Theme::printSite(const int tid,libhtmlpp::HtmlString &output,libhtml const std::string &tag = hel->getTagname(); if (tag == "img") { bool isBanner = false; bool isIcon = false; bool hasLoading = false; bool hasFetchpriority = false; std::string imgSrc; for (auto *attr = hel->firstAttribute(); attr; attr = attr->nextAttribute()) { if (attr->getKey() == "id" && attr->getValue() == "banner") isBanner = true; isIcon = true; if (attr->getKey() == "alt" && attr->getValue() == "sysico") isIcon = true; if (attr->getKey() == "src") imgSrc = attr->getValue(); if (attr->getKey() == "loading") hasLoading = true; if (attr->getKey() == "fetchpriority") hasFetchpriority = true; } if (!isBanner && firstContentImage && !hasFetchpriority) { // Skip small icons (SVG, favicon) — not LCP candidates if (imgSrc.size() > 4 && imgSrc.substr(imgSrc.size() - 4) == ".svg") isIcon = true; if (!isIcon && firstContentImage && !hasFetchpriority) { // First content image is the LCP candidate hel->setAttribute("fetchpriority", "high"); firstContentImage = false; } else if (!isBanner && !hasLoading) { } else if (!isIcon && !hasLoading) { hel->setAttribute("loading", "lazy"); } } Loading Loading
src/theme.cpp +13 −4 Changes for src/theme.cpp: 13 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -515,22 +515,31 @@ void blogi::Theme::printSite(const int tid,libhtmlpp::HtmlString &output,libhtml const std::string &tag = hel->getTagname(); if (tag == "img") { bool isBanner = false; bool isIcon = false; bool hasLoading = false; bool hasFetchpriority = false; std::string imgSrc; for (auto *attr = hel->firstAttribute(); attr; attr = attr->nextAttribute()) { if (attr->getKey() == "id" && attr->getValue() == "banner") isBanner = true; isIcon = true; if (attr->getKey() == "alt" && attr->getValue() == "sysico") isIcon = true; if (attr->getKey() == "src") imgSrc = attr->getValue(); if (attr->getKey() == "loading") hasLoading = true; if (attr->getKey() == "fetchpriority") hasFetchpriority = true; } if (!isBanner && firstContentImage && !hasFetchpriority) { // Skip small icons (SVG, favicon) — not LCP candidates if (imgSrc.size() > 4 && imgSrc.substr(imgSrc.size() - 4) == ".svg") isIcon = true; if (!isIcon && firstContentImage && !hasFetchpriority) { // First content image is the LCP candidate hel->setAttribute("fetchpriority", "high"); firstContentImage = false; } else if (!isBanner && !hasLoading) { } else if (!isIcon && !hasLoading) { hel->setAttribute("loading", "lazy"); } } Loading