fix(cafe24): 옵션 썸네일 — 슬래시 없는 상대경로도 쇼핑몰 주소로, 말풍선에 경로 표시
- "web/product/…" 처럼 앞 슬래시 없는 경로도 image_base 를 붙인다 (http/https/data/blob 이 아니면 전부 쇼핑몰 기준). - 썸네일 말풍선에 실제 이미지 경로를, "없음"에는 불러오지 못한 경로들을 보여준다 — 품목 이미지(/web/product/extra/big/… 추가이미지)가 어디서 오는지 화면에서 바로 확인할 수 있게. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -31,13 +31,20 @@
|
||||
// 썸네일 <img> onerror — data-fallback(줄바꿈 구분)의 다음 후보로, 없으면 "없음".
|
||||
window.cf24ThumbFallback = function (img) {
|
||||
var rest = (img.getAttribute("data-fallback") || "").split("\n").filter(Boolean);
|
||||
var tried = (img.getAttribute("data-tried") ? img.getAttribute("data-tried") + "\n" : "") + img.getAttribute("src");
|
||||
img.setAttribute("data-tried", tried);
|
||||
if (rest.length) {
|
||||
img.setAttribute("data-fallback", rest.slice(1).join("\n"));
|
||||
img.title = "대체 이미지\n" + rest[0];
|
||||
img.src = rest[0];
|
||||
return;
|
||||
}
|
||||
img.onerror = null;
|
||||
img.outerHTML = '<div class="cf24-opt-thumb-empty">없음</div>';
|
||||
var empty = document.createElement("div");
|
||||
empty.className = "cf24-opt-thumb-empty";
|
||||
empty.textContent = "없음";
|
||||
empty.title = "불러오지 못한 경로:\n" + tried;
|
||||
img.replaceWith(empty);
|
||||
};
|
||||
|
||||
window.cf24SetupOptions = function (ctx) {
|
||||
@@ -159,8 +166,9 @@
|
||||
path = String(path || "").trim();
|
||||
if (!path) return "";
|
||||
if (path.indexOf("//") === 0) return "https:" + path;
|
||||
if (path.charAt(0) === "/") return state.imageBase ? state.imageBase + path : "";
|
||||
return path;
|
||||
if (/^(https?:|data:|blob:)/i.test(path)) return path;
|
||||
// "/web/product/…" 또는 앞 슬래시 없는 "web/product/…" — 쇼핑몰 주소 기준
|
||||
return state.imageBase ? state.imageBase + (path.charAt(0) === "/" ? "" : "/") + path : "";
|
||||
}
|
||||
|
||||
// 후보(버튼 이미지 → 연결 이미지 → 품목 image) 중 첫 번째를 보여주고, 깨지면 다음
|
||||
@@ -173,7 +181,8 @@
|
||||
if (u && urls.indexOf(u) < 0) urls.push(u);
|
||||
});
|
||||
if (!urls.length) return THUMB_EMPTY;
|
||||
return '<img class="cf24-opt-thumb" src="' + esc(urls[0]) + '" alt="" title="' + esc(title || "") +
|
||||
// 말풍선에 실제 경로도 보인다 — 썸네일이 이상할 때 어느 이미지인지 바로 확인용
|
||||
return '<img class="cf24-opt-thumb" src="' + esc(urls[0]) + '" alt="" title="' + esc((title ? title + "\n" : "") + urls[0]) +
|
||||
'" data-fallback="' + esc(urls.slice(1).join("\n")) + '" onerror="cf24ThumbFallback(this)" />';
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user