Add placeholder thumbnail on image error
This commit is contained in:
@@ -30,6 +30,20 @@ html {
|
|||||||
object-position: center;
|
object-position: center;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@media (min-width: 801px) {
|
||||||
|
#lightgallery a.thumb-error {
|
||||||
|
width: 250px;
|
||||||
|
height: 250px;
|
||||||
|
margin: 4px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#lightgallery a.thumb-error {
|
||||||
|
background: #2a2a2a;
|
||||||
|
}
|
||||||
|
#lightgallery a.thumb-error img {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
.play-icon {
|
.play-icon {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|||||||
+1
-1
@@ -142,7 +142,7 @@ class Render {
|
|||||||
video ? `<a data-video='${video}'` : `<a href="${previewUrl}"`,
|
video ? `<a data-video='${video}'` : `<a href="${previewUrl}"`,
|
||||||
downloadUrl ? ` data-download-url="${downloadUrl}"` : '',
|
downloadUrl ? ` data-download-url="${downloadUrl}"` : '',
|
||||||
description ? ` data-sub-html='<p>${description}</p>'` : '',
|
description ? ` data-sub-html='<p>${description}</p>'` : '',
|
||||||
` data-download="${this.getFilename(asset)}" data-slide-name="${asset.id}"><img alt="${description}" loading="lazy" src="${thumbnailUrl}"/>`,
|
` data-download="${this.getFilename(asset)}" data-slide-name="${asset.id}"><img alt="${description}" loading="lazy" src="${thumbnailUrl}" onerror="this.closest('a').classList.add('thumb-error')"/>`,
|
||||||
video ? '<div class="play-icon"></div>' : '',
|
video ? '<div class="play-icon"></div>' : '',
|
||||||
'</a>'
|
'</a>'
|
||||||
].join('')
|
].join('')
|
||||||
|
|||||||
Reference in New Issue
Block a user