Skip to content

Commit ea8d997

Browse files
committed
default icon for errored images
1 parent cb4f85d commit ea8d997

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

src/webpage/icons/sad.svg

Lines changed: 1 addition & 0 deletions
Loading

src/webpage/style.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3039,6 +3039,19 @@ fieldset input[type="radio"] {
30393039
font-size: 0.2in;
30403040
padding: 0 0.1in;
30413041
}
3042+
img.error {
3043+
position: relative;
3044+
}
3045+
img.error::after {
3046+
background: var(--secondary-bg) url("/icons/sad.svg");
3047+
background-size: contain;
3048+
content: "";
3049+
width: 100%;
3050+
height: 100%;
3051+
position: absolute;
3052+
top: 0;
3053+
left: 0;
3054+
}
30423055
.gifBox {
30433056
img {
30443057
max-width: 196px;

src/webpage/utils/utils.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,9 @@ export function createImg(
599599
const settings =
600600
localStorage.getItem("gifSetting") || ("hover" as "hover") || "always" || "never";
601601
const img = document.createElement("img");
602+
img.addEventListener("error", () => {
603+
img.classList.add("error");
604+
});
602605
elm ||= img;
603606
if (src && isAnimated(src)) {
604607
img.crossOrigin = "anonymous";

0 commit comments

Comments
 (0)