Skip to content

Commit a0b3903

Browse files
committed
deploy: 5e93b17
1 parent 0d3a41d commit a0b3903

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

pr-246/blogcard.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,16 @@
157157
// 画像を更新
158158
if (ogpData.image && thumbnail) {
159159
thumbnail.classList.remove('blogcard-thumbnail-placeholder');
160-
thumbnail.innerHTML = `<img src="${ogpData.image}" alt="${ogpData.title || ''}" loading="lazy">`;
160+
// 既存の画像を削除
161+
while (thumbnail.firstChild) {
162+
thumbnail.removeChild(thumbnail.firstChild);
163+
}
164+
// 新しいimg要素を安全に作成
165+
const img = document.createElement('img');
166+
img.setAttribute('src', ogpData.image);
167+
img.setAttribute('alt', ogpData.title || '');
168+
img.setAttribute('loading', 'lazy');
169+
thumbnail.appendChild(img);
161170
log('Image updated:', ogpData.image);
162171
} else {
163172
log('No image to update, ogpData.image:', ogpData.image);

0 commit comments

Comments
 (0)