We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0d3a41d commit a0b3903Copy full SHA for a0b3903
pr-246/blogcard.js
@@ -157,7 +157,16 @@
157
// 画像を更新
158
if (ogpData.image && thumbnail) {
159
thumbnail.classList.remove('blogcard-thumbnail-placeholder');
160
- thumbnail.innerHTML = `<img src="${ogpData.image}" alt="${ogpData.title || ''}" loading="lazy">`;
+ // 既存の画像を削除
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);
170
log('Image updated:', ogpData.image);
171
} else {
172
log('No image to update, ogpData.image:', ogpData.image);
0 commit comments